#300: Updated Project and User models to use the new Todo model

This commit is contained in:
Henrik Bohre 2009-05-20 02:06:42 +02:00 committed by Eric Allen
parent e9de70ed95
commit b136816ff1
2 changed files with 9 additions and 0 deletions

View file

@ -20,6 +20,11 @@ class Project < ActiveRecord::Base
:class_name => 'Todo',
:conditions => ["todos.state = ? ", "deferred"],
:order => "show_from"
has_many :pending_todos,
:include => [:context,:tags,:project],
:class_name => 'Todo',
:conditions => ["todos.state = ? ", "pending"],
:order => "show_from"
has_many :notes, :dependent => :delete_all, :order => "created_at DESC"

View file

@ -98,6 +98,10 @@ class User < ActiveRecord::Base
find(:all, :conditions => ['show_from <= ?', Time.zone.now ]).collect { |t| t.activate! }
end
end
has_many :pending_todos,
:class_name => 'Todo',
:conditions => [ 'state = ?', 'pending' ],
:order => 'show_from ASC, todos.created_at DESC'
has_many :completed_todos,
:class_name => 'Todo',
:conditions => ['todos.state = ? AND NOT(todos.completed_at IS NULL)', 'completed'],