mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-26 20:08:51 +01:00
fix #895 by clearing the repeat pattern from todos before the pattern is deleted
cherry-picked from 1.7branch
This commit is contained in:
parent
87bb15460e
commit
bf15175c7b
2 changed files with 12 additions and 0 deletions
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue