diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ed6e5163..f2e2b1ae 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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" @@ -149,7 +130,7 @@ class ApplicationController < ActionController::Base def markdown(text) RedCloth.new(text).to_html end - + # Here's the concept behind this "mobile content negotiation" hack: In # addition to the main, AJAXy Web UI, Tracks has a lightweight low-feature # 'mobile' version designed to be suitablef or use from a phone or PDA. It diff --git a/app/controllers/backend_controller.rb b/app/controllers/backend_controller.rb index 0a96cb30..5fceed53 100644 --- a/app/controllers/backend_controller.rb +++ b/app/controllers/backend_controller.rb @@ -1,3 +1,5 @@ +class CannotAccessContext < RuntimeError; end + class BackendController < ApplicationController wsdl_service_name 'Backend' web_service_api TodoApi diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index fadf2db3..650e100c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 952be857..57095af9 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -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 = "
#{t('todos.feeds.due', :date => format_date(i.due))}
\n" if i.due? diff --git a/app/views/shared/_add_new_item_form.rhtml b/app/views/shared/_add_new_item_form.rhtml index 455f3e16..585d3380 100644 --- a/app/views/shared/_add_new_item_form.rhtml +++ b/app/views/shared/_add_new_item_form.rhtml @@ -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? -%>
diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index fa420799..3509f959 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -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