mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-11 15:12:37 +01:00
migrate toggle_check and destroy and defer and get the functional tests running again
This commit is contained in:
parent
7a893980c2
commit
a832417c59
33 changed files with 412 additions and 314 deletions
|
|
@ -1,5 +1,5 @@
|
|||
class Project < ActiveRecord::Base
|
||||
has_many :todos, :dependent => :delete_all, :include => [:context,:tags]
|
||||
has_many :todos, :dependent => :delete_all
|
||||
|
||||
# TODO: remove these scopes. Can be replaced by the named scopes on the todo relation
|
||||
has_many :not_done_todos,
|
||||
|
|
@ -7,11 +7,6 @@ class Project < ActiveRecord::Base
|
|||
:class_name => 'Todo',
|
||||
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
|
||||
:conditions => ["todos.state = ?", 'active']
|
||||
has_many :not_done_todos_including_hidden,
|
||||
:include => [:context,:tags,:project],
|
||||
:class_name => 'Todo',
|
||||
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
|
||||
:conditions => ["(todos.state = ? OR todos.state = ?)", 'active', 'project_hidden']
|
||||
has_many :done_todos,
|
||||
:include => [:context,:tags,:project],
|
||||
:class_name => 'Todo',
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class Todo < ActiveRecord::Base
|
|||
after_save :save_predecessors
|
||||
|
||||
named_scope :active, :conditions => { :state => 'active' }
|
||||
named_scope :active_or_hidden, :conditions => ["todos.state = ? OR todos.state = ?", 'active', 'project_hidden']
|
||||
named_scope :not_completed, :conditions => ['NOT (todos.state = ? )', 'completed']
|
||||
named_scope :completed, :conditions => ["NOT todos.completed_at IS NULL"]
|
||||
named_scope :are_due, :conditions => ['NOT (todos.due IS NULL)']
|
||||
|
|
@ -215,7 +216,7 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def update_state_from_project
|
||||
if state == 'project_hidden' and !self.project.hidden?
|
||||
if self.state == 'project_hidden' and !self.project.hidden?
|
||||
if self.uncompleted_predecessors.empty?
|
||||
self.state = 'active'
|
||||
else
|
||||
|
|
@ -224,6 +225,7 @@ class Todo < ActiveRecord::Base
|
|||
elsif self.state == 'active' and self.project.hidden?
|
||||
self.state = 'project_hidden'
|
||||
end
|
||||
self.save!
|
||||
end
|
||||
|
||||
def toggle_completion!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue