aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/request_controller.rb13
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/models/info_request.rb4
-rw-r--r--app/models/request_mailer.rb11
-rw-r--r--app/models/track_thing.rb4
-rw-r--r--app/models/user.rb7
-rw-r--r--app/views/request/_sidebar.rhtml16
-rw-r--r--app/views/request_mailer/external_response.rhtml1
-rw-r--r--app/views/request_mailer/requires_admin.rhtml2
9 files changed, 44 insertions, 18 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 2250747e1..7f42eeb7e 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# app/controllers/request_controller.rb:
# Show information about one particular request.
#
@@ -47,7 +46,13 @@ class RequestController < ApplicationController
end
def show
- medium_cache
+ if !MySociety::Config.get('VARNISH_HOST').nil?
+ # If varnish is set up to accept PURGEs, then cache for a
+ # long time
+ long_cache
+ else
+ medium_cache
+ end
@locale = self.locale_from_params()
PublicBody.with_locale(@locale) do
@@ -665,7 +670,7 @@ class RequestController < ApplicationController
)
if !info_request.attention_requested
- info_request.set_described_state('attention_requested')
+ info_request.set_described_state('attention_requested', @user)
info_request.attention_requested = true # tells us if attention has ever been requested
info_request.save!
flash[:notice] = _("This request has been reported for administrator attention")
@@ -712,7 +717,7 @@ class RequestController < ApplicationController
# we don't use @attachment.content_type here, as we want same mime type when cached in cache_attachments above
response.content_type = AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream'
- headers["Content-Disposition"] = "attachment; filename=#{params[:file_name]}"
+
render :text => @attachment.body
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index df016a249..cb6615199 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -127,7 +127,9 @@ module ApplicationHelper
end
def admin_date(date)
- "#{I18n.l(date, :format => "%e %B %Y %H:%M:%S")} (#{_('{{length_of_time}} ago', :length_of_time => time_ago_in_words(date))})"
+ ago_text = _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(date))
+ exact_date = I18n.l(date, :format => "%e %B %Y %H:%M:%S")
+ return "#{exact_date} (#{ago_text})"
end
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index cf82bd854..d09acbcf6 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -553,7 +553,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
@@ -566,7 +566,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 5ea5df802..03d26f237 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -60,13 +60,18 @@ 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?
+ user = set_by
+ else
+ 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
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index 7f6bc9a7e..d0fc62e12 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -218,8 +218,8 @@ 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"),
- :email => _("Then you will be following all new FOI request."),
+ :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
:feed_sortby => 'newest'
diff --git a/app/models/user.rb b/app/models/user.rb
index 57fce429c..a21676f68 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
@@ -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
diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.rhtml
index 2534190f0..d20e27e23 100644
--- a/app/views/request/_sidebar.rhtml
+++ b/app/views/request/_sidebar.rhtml
@@ -8,8 +8,20 @@
</div>
<% if @info_request.described_state != "attention_requested" %>
<h2><%= _('Offensive? Unsuitable?') %></h2>
- <% if @info_request.attention_requested %>
- <p><%= ('The site administrators have reviewed this request and consider it to be suitable for the website.') %></p>
+ <% if @info_request.attention_requested %>
+ <% if @info_request.prominence == 'hidden' %>
+ <%# The eccentric formatting of the following string is in order that it be identical
+ to the corresponding string in request/show.rhtml %>
+ <p><%= _('This request has prominence \'hidden\'. You can only see it because you are logged
+ in as a super user.') %></p>
+ <% elsif @info_request.prominence == 'requester_only' %>
+ <%# The eccentric formatting of the following string is in order that it be identical
+ to the corresponding string in request/show.rhtml %>
+ <p><%= _('This request is hidden, so that only you the requester can see it. Please
+ <a href="%s">contact us</a> if you are not sure why.') % [help_requesting_path] %></p>
+ <% else %>
+ <p><%= _('This request has been marked for review by the site administrators, who have not hidden it at this time. If you believe it should be hidden, please <a href="%s">contact us</a>.') % [help_requesting_path] %></p>
+ <% end %>
<% else %>
<p><%= _('Requests for personal information and vexatious requests are not considered valid for FOI purposes (<a href="/help/about">read more</a>).') %></p>
<p><%= ('If you believe this request is not suitable, you can report it for attention by the site administrators') %></p>
diff --git a/app/views/request_mailer/external_response.rhtml b/app/views/request_mailer/external_response.rhtml
new file mode 100644
index 000000000..e9858f03f
--- /dev/null
+++ b/app/views/request_mailer/external_response.rhtml
@@ -0,0 +1 @@
+<%=@body%>
diff --git a/app/views/request_mailer/requires_admin.rhtml b/app/views/request_mailer/requires_admin.rhtml
index acd37f405..06a798792 100644
--- a/app/views/request_mailer/requires_admin.rhtml
+++ b/app/views/request_mailer/requires_admin.rhtml
@@ -1,5 +1,5 @@
---------------------------------------------------------------------
-<%=@info_request.user.name%> <%= _('has reported an')%> <%=@info_request.law_used_short%>
+<%=@reported_by.name%> <%= _('has reported an')%> <%=@info_request.law_used_short%>
<%= _('response as needing administrator attention. Take a look, and reply to this
email to let them know what you are going to do about it.')%>