mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
remove duplication of all_done_todos and done_todos in project and context container
This commit is contained in:
parent
38057054ab
commit
cdfb65d529
3 changed files with 26 additions and 30 deletions
|
|
@ -268,4 +268,26 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def all_done_todos_for(object)
|
||||
object_name = object.class.name.downcase # context or project
|
||||
@source_view = object_name
|
||||
@page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name)
|
||||
|
||||
@done = object.todos.completed.paginate :page => params[:page], :per_page => 20, :order => 'completed_at DESC', :include => Todo::DEFAULT_INCLUDES
|
||||
@count = @done.size
|
||||
render :template => 'todos/all_done'
|
||||
end
|
||||
|
||||
def done_todos_for(object)
|
||||
object_name = object.class.name.downcase # context or project
|
||||
@source_view = object_name
|
||||
eval("@#{object_name} = object")
|
||||
@page_title = t("#{object_name.pluralize}.completed_tasks_title", "#{object_name}_name".to_sym => object.name)
|
||||
|
||||
@done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(object)
|
||||
@count = @done_today.size + @done_rest_of_week.size + @done_rest_of_month.size
|
||||
|
||||
render :template => 'todos/done'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue