diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 4e946f5c..e2bac2ce 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -4,7 +4,7 @@ class TodosController < ApplicationController skip_before_filter :login_required, :only => [:index] prepend_before_filter :login_or_feed_token_required, :only => [:index] - append_before_filter :init, :except => [ :destroy, :completed, :completed_archive, :check_deferred, :toggle_check, :toggle_star, :edit, :update, :create ] + append_before_filter :init, :except => [ :destroy, :completed, :completed_archive, :check_deferred, :toggle_check, :toggle_star, :edit, :update, :create, :calendar ] append_before_filter :get_todo_from_params, :only => [ :edit, :toggle_check, :toggle_star, :show, :update, :destroy ] session :off, :only => :index, :if => Proc.new { |req| is_feed_request(req) } @@ -404,7 +404,37 @@ class TodosController < ApplicationController format.js {render :action => 'update'} end end - + + def calendar + @source_view = params['_source_view'] || 'calendar' + @page_title = "TRACKS::Calendar" + + due_today_date = Time.zone.now + due_this_week_date = Time.zone.now.end_of_week + due_next_week_date = due_this_week_date + 7.days + due_this_month_date = Time.zone.now.end_of_month + + @due_today = current_user.todos.find(:all, + :conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due <= ?', 'active', 'deferred', due_today_date], + :order => "due") + @due_this_week = current_user.todos.find(:all, + :conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due > ? AND todos.due <= ?', 'active', 'deferred', due_today_date, due_this_week_date], + :order => "due") + @due_next_week = current_user.todos.find(:all, + :conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due > ? AND todos.due <= ?', 'active', 'deferred', due_this_week_date, due_next_week_date], + :order => "due") + @due_this_month = current_user.todos.find(:all, + :conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due > ? AND todos.due <= ?', 'active', 'deferred', due_next_week_date, due_this_month_date], + :order => "due") + @due_after_this_month = current_user.todos.find(:all, + :conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due > ?', 'active', 'deferred', due_this_month_date], + :order => "due") + + respond_to do |format| + format.html + format.ics { render :text => 'Not implemented yet', :status => 200 } + end + end private diff --git a/app/views/todos/calendar.html.erb b/app/views/todos/calendar.html.erb new file mode 100644 index 00000000..f887ffac --- /dev/null +++ b/app/views/todos/calendar.html.erb @@ -0,0 +1,34 @@ +
+ +
+

Due today

+ <%= render :partial => "todos/todo", :collection => @due_today %> +
+ +
+

Due this week

+ <%= render :partial => "todos/todo", :collection => @due_this_week %> +
+ +
+

Due next week

+ <%= render :partial => "todos/todo", :collection => @due_next_week %> +
+ +
+

Due rest of this month

+ <%= render :partial => "todos/todo", :collection => @due_this_month %> +
+ +
+

Due next month and later

+ <%= render :partial => "todos/todo", :collection => @due_after_this_month %> +
+ +
+
+ + +

+

iCal - Get this calendar in iCal-format to add to your own calendar

+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e0a91a43..222f7619 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,6 +46,8 @@ ActionController::Routing::Routes.draw do |map| todos.tag 'todos/tag/:name.m', :action => "tag", :format => 'm' todos.tag 'todos/tag/:name', :action => "tag", :name => /.*/ + todos.calendar 'calendar', :action => "calendar" + todos.mobile 'mobile', :action => "index", :format => 'm' todos.mobile_abbrev 'm', :action => "index", :format => 'm' todos.mobile_abbrev_new 'm/new', :action => "new", :format => 'm'