diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index aa2328dd..d483b611 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -3,6 +3,8 @@ class ContextController < ApplicationController helper :todo prepend_before_filter :login_required + before_filter :init, :except => [:create, :destroy, :order] + before_filter :init_todos, :only => :show layout "standard", :except => :date_preview def index @@ -14,7 +16,6 @@ class ContextController < ApplicationController # Set page title, and collect existing contexts in @contexts # def list - self.init @page_title = "TRACKS::List Contexts" respond_to do |wants| wants.html @@ -26,9 +27,6 @@ class ContextController < ApplicationController # e.g. /context/ shows just . # def show - init - check_user_set_context - init_todos @page_title = "TRACKS::Context: #{@context.name}" end @@ -64,7 +62,6 @@ class ContextController < ApplicationController # Edit the details of the context # def update - self.init check_user_set_context params['context'] ||= {} success_text = if params['field'] == 'name' && params['value'] diff --git a/tracks/app/controllers/feed_controller.rb b/tracks/app/controllers/feed_controller.rb index 9abfd48a..13ae1880 100644 --- a/tracks/app/controllers/feed_controller.rb +++ b/tracks/app/controllers/feed_controller.rb @@ -8,6 +8,7 @@ class FeedController < ApplicationController before_filter :check_token_against_user_word, :except => 'index' prepend_before_filter :login_required, :only => 'index' + before_filter :prepare_for_feed, :only => [:rss, :text, :ical] def index @@ -18,7 +19,6 @@ class FeedController < ApplicationController # Build an RSS feed def rss - prepare_for_feed headers["Content-Type"] = "text/xml; charset=utf-8" end @@ -31,7 +31,6 @@ class FeedController < ApplicationController # curl [url from "TXT" link on todo/list] # def text - prepare_for_feed if params.key?('context') @contexts = [ @user.contexts.find(params['context']) ] else @@ -45,7 +44,6 @@ class FeedController < ApplicationController # Due dates are supported, and notes are included. # def ical - prepare_for_feed if params.key?('context') @contexts = [ @user.contexts.find(params['context']) ] else diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index 55a0c429..9e88a4a1 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -4,6 +4,8 @@ class ProjectController < ApplicationController helper :todo prepend_before_filter :login_required + before_filter :init, :except => [:create, :destroy, :order, :toggle_project_done] + before_filter :init_todos, :only => :show layout "standard", :except => :date_preview @@ -16,7 +18,6 @@ class ProjectController < ApplicationController # Set page title, and collect existing projects in @projects # def list - init init_project_hidden_todo_counts @page_title = "TRACKS::List Projects" respond_to do |wants| @@ -29,8 +30,6 @@ class ProjectController < ApplicationController # e.g. /project/show/ shows just . # def show - init - init_todos @notes = @project.notes @page_title = "TRACKS::Project: #{@project.name}" @@ -89,7 +88,6 @@ class ProjectController < ApplicationController # Edit the details of the project # def update - self.init check_user_set_project params['project'] ||= {} if params['project']['state'] diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 86f04bd1..c8b6da67 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -3,18 +3,17 @@ class TodoController < ApplicationController model :user model :project model :context - + helper :todo prepend_before_filter :login_required - append_before_filter :init, :except => [ :destroy, :completed, :completed_archive ] + append_before_filter :init, :except => [ :destroy, :completed, :completed_archive, :check_tickler ] layout "standard", :except => :date_preview # Main method for listing tasks # Set page title, and fill variables with contexts and done and not-done tasks # Number of completed actions to show is determined by a setting in settings.yml def index - init @projects = @user.projects.find(:all, :include => [ :todos ]) @contexts = @user.contexts.find(:all, :include => [ :todos ]) @@ -60,7 +59,6 @@ class TodoController < ApplicationController end def create - init @item = @user.todos.build p = params['request'] || params @item.attributes = p['todo'] @@ -113,12 +111,10 @@ class TodoController < ApplicationController end def edit - init @item = check_user_return_item end def show - init item = check_user_return_item respond_to do |wants| wants.xml { render :xml => item.to_xml( :root => 'todo', :except => :user_id ) } @@ -128,7 +124,6 @@ class TodoController < ApplicationController # Toggles the 'done' status of the action # def toggle_check - init @item = check_user_return_item @item.toggle_completion() @saved = @item.save @@ -149,7 +144,6 @@ class TodoController < ApplicationController end def update - init @item = check_user_return_item @original_item_context_id = @item.context_id @original_item_project_id = @item.project_id @@ -244,7 +238,6 @@ class TodoController < ApplicationController end def tickler - init @source_view = 'deferred' @page_title = "TRACKS::Tickler" @tickles = @user.todos.find_in_state(:all, :deferred, :order => "show_from ASC") diff --git a/tracks/test/functional/todo_controller_test.rb b/tracks/test/functional/todo_controller_test.rb index 7444427f..164a58ad 100644 --- a/tracks/test/functional/todo_controller_test.rb +++ b/tracks/test/functional/todo_controller_test.rb @@ -59,11 +59,11 @@ class TodoControllerTest < Test::Unit::TestCase def test_update_item t = Todo.find(1) @request.session['user_id'] = users(:admin_user).id - xhr :post, :update, :id => 1, :_source_view => 'todo', "item"=>{"context_id"=>"1", "project_id"=>"2", "id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"11/30/2006"} + xhr :post, :update, :id => 1, :_source_view => 'todo', "item"=>{"context_id"=>"1", "project_id"=>"2", "id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"2006-11-30"} #assert_rjs :page, "item-1-container", :visual_effect, :highlight, :duration => '1' t = Todo.find(1) assert_equal "Call Warren Buffet to find out how much he makes per day", t.description - assert_equal Date.parse("11/30/2006"), t.due + assert_equal "2006-11-30", t.due end