From 6f66fe8a30083a2fa49618b4dad828c0cef3b310 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Mon, 20 Aug 2012 07:16:55 +0100 Subject: External requests ought not to be considered old_unclassified We certainly do not want to send reminder emails for such requests, for example, since we do not know the email address to send them to. --- app/models/info_request.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 2f4a89d91..6426f6ea8 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -942,7 +942,7 @@ public last_response_created_at = last_event_time_clause('response') age = extra_params[:age_in_days] ? extra_params[:age_in_days].days : OLD_AGE_IN_DAYS params = {:select => "*, #{last_response_created_at} as last_response_time", - :conditions => ["awaiting_description = ? and #{last_response_created_at} < ? and url_title != 'holding_pen'", + :conditions => ["awaiting_description = ? and #{last_response_created_at} < ? and url_title != 'holding_pen' and user_id is not null", true, Time.now() - age], :order => "last_response_time"} params[:limit] = extra_params[:limit] if extra_params[:limit] @@ -960,6 +960,7 @@ public end def is_old_unclassified? + return false if user_id.nil? return false if !awaiting_description return false if url_title == 'holding_pen' last_response_event = get_last_response_event -- cgit v1.2.3 From 99457f15722b3326ba11ecb3003c3dd50b70a9c4 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Mon, 20 Aug 2012 08:00:03 +0100 Subject: Fix tests Also make the InfoRequest#is_old_unclassified? method a little more conservative, by returning false only is the is_external? method returns true. This makes it subtly inconsistent with InfoRequest.find_old_unclassified, but it is better I think to be subtly inconsistent than to risk breaking things that used to work. --- app/models/info_request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 6426f6ea8..e88c3a95f 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -960,7 +960,7 @@ public end def is_old_unclassified? - return false if user_id.nil? + return false if is_external? return false if !awaiting_description return false if url_title == 'holding_pen' last_response_event = get_last_response_event -- cgit v1.2.3 From dae632d5b6a636ee0976151c764831015a67f3d5 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Mon, 20 Aug 2012 11:08:01 +0100 Subject: Do not send email for external requests --- app/models/info_request.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index e88c3a95f..ba7e44c08 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -456,7 +456,7 @@ public if !allow if self.handle_rejected_responses == 'bounce' - RequestMailer.deliver_stopped_responses(self, email, raw_email_data) + RequestMailer.deliver_stopped_responses(self, email, raw_email_data) if !is_external? elsif self.handle_rejected_responses == 'holding_pen' InfoRequest.holding_pen_request.receive(email, raw_email_data, false, reason) elsif self.handle_rejected_responses == 'blackhole' @@ -565,7 +565,7 @@ public self.calculate_event_states - if self.requires_admin? + if self.requires_admin? && !self.is_external? RequestMailer.deliver_requires_admin(self, set_by) end end -- cgit v1.2.3 From f2115fe4357d232d0e8a373881790a9a38ee80f5 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Mon, 20 Aug 2012 15:25:00 +0100 Subject: Fail with NotFound if request slug doesn't exist Closes #554. --- app/models/info_request.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index ba7e44c08..23e18b858 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -223,7 +223,7 @@ class InfoRequest < ActiveRecord::Base incoming_message.clear_in_database_caches! end end - + # For debugging def InfoRequest.profile_search(query) t = Time.now.usec @@ -246,7 +246,9 @@ public # For request with same title as others, add on arbitary numeric identifier unique_url_title = url_title suffix_num = 2 # as there's already one without numeric suffix - while not InfoRequest.find_by_url_title(unique_url_title, :conditions => self.id.nil? ? nil : ["id <> ?", self.id] ).nil? + while not InfoRequest.find_by_url_title(unique_url_title, + :conditions => self.id.nil? ? nil : ["id <> ?", self.id] + ).nil? unique_url_title = url_title + "_" + suffix_num.to_s suffix_num = suffix_num + 1 end -- cgit v1.2.3