preserve database integrity for recurring todos when deleting project or context. Fixes #880. Fixes #895

This commit is contained in:
Reinier Balt 2010-04-04 18:12:52 +02:00
parent f1a3ec2d7d
commit 3cc3253ce3
4 changed files with 8 additions and 0 deletions

View file

@ -1,6 +1,7 @@
class Context < ActiveRecord::Base
has_many :todos, :dependent => :delete_all, :include => :project, :order => "todos.completed_at DESC"
has_many :recurring_todos, :dependent => :delete_all
belongs_to :user
named_scope :active, :conditions => { :hide => false }

View file

@ -1,6 +1,7 @@
class Project < ActiveRecord::Base
has_many :todos, :dependent => :delete_all, :include => :context
has_many :notes, :dependent => :delete_all, :order => "created_at DESC"
has_many :recurring_todos
belongs_to :default_context, :class_name => "Context", :foreign_key => "default_context_id"
belongs_to :user

View file

@ -631,6 +631,11 @@ class RecurringTodo < ActiveRecord::Base
end
starred?
end
def remove_from_project!
self.project = nil
self.save
end
def inc_occurences
self.occurences_count += 1