fix #895 by clearing the repeat pattern from todos before the pattern is deleted

cherry-picked from 1.7branch
This commit is contained in:
Reinier Balt 2010-08-19 11:25:04 +02:00
parent 87bb15460e
commit bf15175c7b
2 changed files with 12 additions and 0 deletions

View file

@ -121,6 +121,9 @@ class ContextsController < ApplicationController
# actions, you'll get a warning dialogue. If you choose to go ahead, any
# actions in the context will also be deleted.
def destroy
# make sure the deleted recurring patterns are removed from associated todos
@context.recurring_todos.each { |rt| rt.clear_todos_association } unless @context.recurring_todos.nil?
@context.destroy
respond_to do |format|
format.js { @down_count = current_user.contexts.size }

View file

@ -717,6 +717,15 @@ class RecurringTodo < ActiveRecord::Base
self.save
end
def clear_todos_association
unless todos.nil?
self.todos.each do |t|
t.recurring_todo = nil
t.save
end
end
end
def inc_occurences
self.occurences_count += 1
self.save