From ca4ae410e70ab490ae4c8cad8839f41783c89ef7 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 15:02:30 +1100 Subject: Extract method --- app/models/info_request.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 156399b99..83a57b4b2 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -555,6 +555,13 @@ public ['requires_admin', 'error_message', 'attention_requested'].include?(described_state) end + # Report this request for administrator attention + def report!(reason, message, user) + set_described_state('attention_requested', user, "Reason: #{reason}\n\n#{message}") + self.attention_requested = true # tells us if attention has ever been requested + save! + end + # 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 -- cgit v1.2.3 From 0078c3d4eacb3107766a057a42644b9066f15c4a Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 15:06:24 +1100 Subject: Wrap in a transaction --- app/models/info_request.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 83a57b4b2..f63c10e0a 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -557,9 +557,11 @@ public # Report this request for administrator attention def report!(reason, message, user) - set_described_state('attention_requested', user, "Reason: #{reason}\n\n#{message}") - self.attention_requested = true # tells us if attention has ever been requested - save! + ActiveRecord::Base.transaction do + set_described_state('attention_requested', user, "Reason: #{reason}\n\n#{message}") + self.attention_requested = true # tells us if attention has ever been requested + save! + end end # change status, including for last event for later historical purposes -- cgit v1.2.3 From 57ed2c6f014e07d242ae7ffe147c1bd215764669 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 17:24:40 +1100 Subject: Reasons that request can be reported now stored in model --- app/models/info_request.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index f63c10e0a..68b837c7d 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -108,6 +108,12 @@ class InfoRequest < ActiveRecord::Base states end + # Possible reasons that a request could be reported for administrator attention + def report_reasons + ["Contains defamatory material", "Not a valid request", "Request for personal information", + "Contains personal information", "Vexatious", "Other"] + end + def must_be_valid_state errors.add(:described_state, "is not a valid state") if !InfoRequest.enumerate_states.include? described_state -- cgit v1.2.3