Remove 'project_hidden' state

Compute it using project/context state

Notable change:
todo.hidden? now also returns true if the todo is completed
This commit is contained in:
Carsten Otto 2016-01-24 00:52:23 +01:00
parent 543f49ed8a
commit ed3bca22a4
12 changed files with 66 additions and 106 deletions

View file

@ -27,7 +27,7 @@ class Project < ActiveRecord::Base
aasm :column => :state do
state :active, :initial => true
state :hidden, :enter => :hide_todos, :exit => :unhide_todos
state :hidden
state :completed, :enter => :set_completed_at_date, :exit => :clear_completed_at_date
event :activate do
@ -53,24 +53,6 @@ class Project < ActiveRecord::Base
self.last_reviewed = Time.now
end
def hide_todos
todos.each do |t|
unless t.completed? || t.deferred?
t.hide!
t.save
end
end
end
def unhide_todos
todos.each do |t|
if t.project_hidden?
t.unhide!
t.save
end
end
end
def set_completed_at_date
self.completed_at = Time.zone.now
end