create projects as reviewed at creation time

Fixes #1788
This commit is contained in:
Carsten Otto 2015-05-22 23:12:45 +02:00
parent 556c68c2e6
commit 6014ce7a6f
4 changed files with 20 additions and 3 deletions

View file

@ -14,6 +14,8 @@ class Project < ActiveRecord::Base
scope :with_name_or_description, lambda { |body| where("name LIKE ? OR description LIKE ?", body, body) }
scope :with_namepart, lambda { |body| where("name LIKE ?", body + '%') }
before_create :set_last_reviewed_now
validates_presence_of :name
validates_length_of :name, :maximum => 255
validates_uniqueness_of :name, :scope => "user_id"
@ -47,6 +49,10 @@ class Project < ActiveRecord::Base
NullProject.new
end
def set_last_reviewed_now
self.last_reviewed = Time.now
end
def hide_todos
todos.each do |t|
unless t.completed? || t.deferred?