diff options
author | Azul <azul@leap.se> | 2013-11-06 10:55:25 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-11-06 10:55:25 +0100 |
commit | ebc60f3aba1ca08e454ba5e91f49905df2e5fa13 (patch) | |
tree | 48eeab39861be9d9f2993e316cf0118071b917a0 /help/app/models | |
parent | d620fd42925f1d3d29a66bb61a75bed8c2bdaf8f (diff) |
Ticket.destroy_all_from(user) - remove all tickets created by a user
We'll use this to clean up after user destruction
Diffstat (limited to 'help/app/models')
-rw-r--r-- | help/app/models/ticket.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb index 8066d0d..74f2050 100644 --- a/help/app/models/ticket.rb +++ b/help/app/models/ticket.rb @@ -24,6 +24,7 @@ class Ticket < CouchRest::Model::Base design do view :by_updated_at view :by_created_at + view :by_created_by view :by_is_open_and_created_at view :by_is_open_and_updated_at @@ -40,6 +41,12 @@ class Ticket < CouchRest::Model::Base @selection.tickets end + def self.destroy_all_from(user) + self.by_created_by.key(user.id).each do |ticket| + ticket.destroy + end + end + def is_creator_validated? !!created_by end |