diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2013-03-04 14:16:37 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2013-03-04 14:16:37 +1100 |
commit | f60ada47d4e7aabe0dce152109cb0d91865929da (patch) | |
tree | 6e2b140e5f468cb25f3980da2931544dcdcb3350 /app/models/info_request.rb | |
parent | 28e65f615c24b96225d24f3f1e0c03f229f8fe4e (diff) |
Refactor functionality from controller to model
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 191f10018..237364f56 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -549,6 +549,7 @@ public # change status, including for last event for later historical purposes def set_described_state(new_state, set_by = nil, message = "") + old_described_state = described_state ActiveRecord::Base.transaction do self.awaiting_description = false last_event = self.info_request_events.last @@ -566,6 +567,20 @@ public RequestMailer.deliver_requires_admin(self, set_by, message) end end + + unless set_by.nil? || is_actual_owning_user?(set_by) || described_state == 'attention_requested' + # Log the status change by someone other than the requester + event = log_event("status_update", + { :user_id => set_by.id, + :old_described_state => old_described_state, + :described_state => described_state, + }) + # Create a classification event for league tables + RequestClassification.create!(:user_id => set_by.id, + :info_request_event_id => event.id) + + RequestMailer.deliver_old_unclassified_updated(self) if !is_external? + end end # Work out what the situation of the request is. In addition to values of |