From f60ada47d4e7aabe0dce152109cb0d91865929da Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Mon, 4 Mar 2013 14:16:37 +1100 Subject: Refactor functionality from controller to model --- app/models/info_request.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'app/models/info_request.rb') 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 -- cgit v1.2.3