From f560987ab0d3ea3471837a2b30d30c7101dc5616 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 12 Jun 2012 09:55:16 +0100 Subject: Make emails requesting admin attention appear to come from the user who requested the attention, not the user who made the original request. --- app/models/info_request.rb | 4 ++-- app/models/request_mailer.rb | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'app/models') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 095a1b1af..45819bfe7 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -519,7 +519,7 @@ public end # change status, including for last event for later historical purposes - def set_described_state(new_state) + def set_described_state(new_state, set_by = nil) ActiveRecord::Base.transaction do self.awaiting_description = false last_event = self.get_last_event @@ -532,7 +532,7 @@ public self.calculate_event_states if self.requires_admin? - RequestMailer.deliver_requires_admin(self) + RequestMailer.deliver_requires_admin(self, set_by) end end diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index 8e6e65a26..c208923f3 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -45,8 +45,12 @@ class RequestMailer < ApplicationMailer end # An FOI response is outside the scope of the system, and needs admin attention - def requires_admin(info_request) - @from = info_request.user.name_and_email + def requires_admin(info_request, set_by = nil) + if !set_by.nil? + @from = set_by.name_and_email + else + @from = info_request.user.name_and_email + end @recipients = contact_from_name_and_email @subject = _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title) url = main_url(request_url(info_request)) -- cgit v1.2.3 From 05d0d583cb03182e0d7c246c84e7f3ccd55a51a1 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 12 Jun 2012 11:36:26 +0100 Subject: Return column name when iterating over admin fields. --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/user.rb b/app/models/user.rb index 57fce429c..573649b8f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -409,7 +409,7 @@ class User < ActiveRecord::Base columns = self.class.content_columns.map{|c| c if %w(created_at updated_at admin_level email_confirmed).include?(c.name) }.compact end columns.each do |column| - yield(column.human_name, self.send(column.name), column.type.to_s) + yield(column.human_name, self.send(column.name), column.type.to_s, column.name) end end -- cgit v1.2.3 From e419a63a5dd8cfd2d15e0774710c63baeedab749 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 15 Jun 2012 08:41:09 +0100 Subject: typo in user-facing string --- app/models/track_thing.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 7f6bc9a7e..43a429c8e 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -219,7 +219,7 @@ class TrackThing < ActiveRecord::Base :title_in_rss => _("New Freedom of Information requests"), # Authentication :web => _("To be follow new requests"), - :email => _("Then you will be following all new FOI request."), + :email => _("Then you will be following all new FOI requests."), :email_subject => _("Confirm you want to follow new requests"), # RSS sorting :feed_sortby => 'newest' -- cgit v1.2.3 From f62341a2a61e3ef87b4aae460e84405ba2c30d87 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 15 Jun 2012 08:41:37 +0100 Subject: another typo --- app/models/track_thing.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 43a429c8e..d0fc62e12 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -218,7 +218,7 @@ class TrackThing < ActiveRecord::Base :title_in_email => _("New Freedom of Information requests"), :title_in_rss => _("New Freedom of Information requests"), # Authentication - :web => _("To be follow new requests"), + :web => _("To follow new requests"), :email => _("Then you will be following all new FOI requests."), :email_subject => _("Confirm you want to follow new requests"), # RSS sorting -- cgit v1.2.3 From 363e3aaeea5d185e47e22825bad865c31e3e6ed8 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 19 Jun 2012 09:13:16 +0100 Subject: Correctly name the person who has requested something for admin attention --- app/models/request_mailer.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app/models') diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index c208923f3..1b0bb48b9 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -47,15 +47,16 @@ class RequestMailer < ApplicationMailer # An FOI response is outside the scope of the system, and needs admin attention def requires_admin(info_request, set_by = nil) if !set_by.nil? - @from = set_by.name_and_email + user = set_by else - @from = info_request.user.name_and_email + user = info_request.user end + @from = user.name_and_email @recipients = contact_from_name_and_email @subject = _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title) url = main_url(request_url(info_request)) admin_url = request_admin_url(info_request) - @body = {:info_request => info_request, :url => url, :admin_url => admin_url } + @body = {:reported_by => user, :info_request => info_request, :url => url, :admin_url => admin_url } end # Tell the requester that a new response has arrived -- cgit v1.2.3 From 08dac0261325cd757b7146f9626f3c7b48cc672c Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 20 Jun 2012 10:11:03 +0100 Subject: Only invalidate a user's cached requests when their *name* changes. Otherwise we issue PURGEs every time, for example, we send out email alerts. --- app/models/user.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/user.rb b/app/models/user.rb index 573649b8f..a21676f68 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -438,8 +438,9 @@ class User < ActiveRecord::Base after_save(:purge_in_cache) def purge_in_cache - # XXX should only be if specific attributes have changed - self.info_requests.each {|x| x.purge_in_cache} + if self.name_changed? + self.info_requests.each {|x| x.purge_in_cache} + end end end -- cgit v1.2.3