clean ups

This commit is contained in:
Reinier Balt 2011-02-26 14:20:51 +01:00
parent b53fbc64dc
commit 36f007a087
6 changed files with 19 additions and 29 deletions

View file

@ -4,19 +4,6 @@
require_dependency "login_system"
require_dependency "tracks/source_view"
require "redcloth"
require 'date'
require 'time'
# Commented the following line because of #744. It prevented rake db:migrate to
# run because this tag went looking for the taggings table that did not exist
# when you feshly create a new database Old comment: We need this in development
# mode, or you get 'method missing' errors
#
# Tag
class CannotAccessContext < RuntimeError; end
class ApplicationController < ActionController::Base
@ -24,12 +11,11 @@ class ApplicationController < ActionController::Base
helper :application
include LoginSystem
helper_method :current_user, :prefs
helper_method :current_user, :prefs, :format_date, :markdown
layout proc{ |controller| controller.mobile? ? "mobile" : "standard" }
exempt_from_layout /\.js\.erb$/
before_filter :set_session_expiration
before_filter :set_time_zone
before_filter :set_zindex_counter
@ -38,11 +24,6 @@ class ApplicationController < ActionController::Base
prepend_before_filter :enable_mobile_content_negotiation
after_filter :set_charset
include ActionView::Helpers::TextHelper
include ActionView::Helpers::SanitizeHelper
extend ActionView::Helpers::SanitizeHelper::ClassMethods
helper_method :format_date, :markdown
# By default, sets the charset to UTF-8 if it isn't already set
def set_charset
headers["Content-Type"] ||= "text/html; charset=UTF-8"

View file

@ -1,3 +1,5 @@
class CannotAccessContext < RuntimeError; end
class BackendController < ApplicationController
wsdl_service_name 'Backend'
web_service_api TodoApi

View file

@ -47,10 +47,11 @@ class ProjectsController < ApplicationController
init_data_for_sidebar unless mobile?
@page_title = t('projects.page_title', :project => @project.name)
@not_done = @project.todos.active_or_hidden
@deferred = @project.deferred_todos
@pending = @project.pending_todos
@done = @project.todos.find_in_state(:all, :completed, :order => "todos.completed_at DESC", :limit => current_user.prefs.show_number_completed, :include => [:context])
@not_done = @project.todos.active_or_hidden(:include => [:tags, :context, :predecessors])
@deferred = @project.deferred_todos(:include => [:tags, :context, :predecessors])
@pending = @project.pending_todos(:include => [:tags, :context, :predecessors])
@done = @project.todos.find_in_state(:all, :completed,
:order => "todos.completed_at DESC", :limit => current_user.prefs.show_number_completed, :include => [:context, :tags, :predecessors])
@count = @not_done.size
@down_count = @count + @deferred.size + @pending.size
@ -59,6 +60,7 @@ class ProjectsController < ApplicationController
@default_tags = @project.default_tags
@new_note = current_user.notes.new
@new_note.project_id = @project.id
@contexts = current_user.contexts
respond_to do |format|
format.html
format.m &render_project_mobile

View file

@ -13,6 +13,10 @@ class TodosController < ApplicationController
protect_from_forgery :except => :check_deferred
# these are needed for todo_feed_content. TODO: remove this view stuff from controller
include ActionView::Helpers::SanitizeHelper
extend ActionView::Helpers::SanitizeHelper::ClassMethods
def index
@projects = current_user.projects.find(:all, :include => [:default_context])
@contexts = current_user.contexts.find(:all)
@ -981,6 +985,7 @@ class TodosController < ApplicationController
end
def todo_feed_content
# TODO: move view stuff into view, also the includes at the top
lambda do |i|
item_notes = sanitize(markdown( i.notes )) if i.notes?
due = "<div>#{t('todos.feeds.due', :date => format_date(i.due))}</div>\n" if i.due?

View file

@ -1,7 +1,7 @@
<%
@initial_context_name = @context.name unless @context.nil?
@initial_context_name ||= @project.default_context.name unless @project.nil? || @project.default_context.nil?
@initial_context_name ||= current_user.contexts.first.name unless current_user.contexts.first.nil?
@initial_context_name ||= @contexts.first.name unless @contexts.first.nil?
@initial_project_name = @project.name unless @project.nil?
-%>
<div id="todo_new_action_container">

View file

@ -7,8 +7,8 @@ Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password
if response.respond_to? :selenium
selenium.wait_for_page_to_load(5000)
end
logout_string = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
response.should contain(/#{logout_string}/)
logout_regexp = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
response.should contain(logout_regexp)
@current_user = User.find_by_login(username)
end