diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/info_request_event.rb | 3 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 76f50c8d5..c2f515b6b 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request_event.rb,v 1.85 2009-07-03 11:43:37 francis Exp $ +# $Id: info_request_event.rb,v 1.86 2009-07-21 12:09:30 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -44,6 +44,7 @@ class InfoRequestEvent < ActiveRecord::Base 'edit_outgoing', # outgoing message edited in admin interface 'edit_comment', # comment edited in admin interface 'destroy_incoming', # deleted an incoming message + 'destroy_outgoing', # deleted an outgoing message 'redeliver_incoming', # redelivered an incoming message elsewhere 'manual', # you did something in the db by hand 'response', diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 253bd000d..6d1900d64 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -22,7 +22,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: outgoing_message.rb,v 1.86 2009-06-30 16:30:28 francis Exp $ +# $Id: outgoing_message.rb,v 1.87 2009-07-21 12:09:30 francis Exp $ class OutgoingMessage < ActiveRecord::Base strip_attributes! @@ -220,6 +220,17 @@ class OutgoingMessage < ActiveRecord::Base return text end + def fully_destroy + ActiveRecord::Base.transaction do + info_request_event = InfoRequestEvent.find_by_outgoing_message_id(self.id) + info_request_event.track_things_sent_emails.each { |a| a.destroy } + info_request_event.user_info_request_sent_alerts.each { |a| a.destroy } + info_request_event.destroy + self.destroy + end + end + + end |