aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_controller.rb47
-rw-r--r--app/controllers/admin_user_controller.rb3
-rw-r--r--app/controllers/application_controller.rb26
-rw-r--r--app/controllers/request_controller.rb19
-rw-r--r--app/controllers/track_controller.rb26
-rw-r--r--app/controllers/user_controller.rb2
-rwxr-xr-xapp/helpers/link_to_helper.rb4
-rw-r--r--app/models/incoming_message.rb1
-rw-r--r--app/models/info_request.rb19
-rw-r--r--app/models/info_request_event.rb42
-rw-r--r--app/models/outgoing_message.rb5
-rw-r--r--app/models/post_redirect.rb2
-rw-r--r--app/models/profile_photo.rb2
-rw-r--r--app/models/public_body.rb25
-rw-r--r--app/models/purge_request.rb39
-rw-r--r--app/models/raw_email.rb2
-rw-r--r--app/models/request_mailer.rb2
-rw-r--r--app/models/track_thing.rb18
-rw-r--r--app/models/user.rb7
-rw-r--r--app/views/general/search.rhtml3
-rw-r--r--app/views/request/show.rhtml4
-rw-r--r--app/views/user/confirm.rhtml4
-rw-r--r--app/views/user/show.rhtml6
-rw-r--r--app/views/user/sign.rhtml5
24 files changed, 214 insertions, 99 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index adb506b91..884d7e540 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -36,6 +36,8 @@ class AdminController < ApplicationController
# also force a search reindexing (so changed text reflected in search)
info_request.reindex_request_events
+ # and remove from varnsi
+ info_request.purge_in_cache
end
# Expire cached attachment files for a user
@@ -44,23 +46,40 @@ class AdminController < ApplicationController
expire_for_request(info_request)
end
end
- private
- def authenticate
- config_username = MySociety::Config.get('ADMIN_USERNAME', '')
- config_password = MySociety::Config.get('ADMIN_PASSWORD', '')
- if !config_username.empty? && !config_password.empty?
- authenticate_or_request_with_http_basic do |user_name, password|
- if user_name == config_username && password == config_password
- session[:using_admin] = 1
- request.env['REMOTE_USER'] = user_name
- else
- request_http_basic_authentication
+ private
+
+ def authenticate
+ if MySociety::Config.get('SKIP_ADMIN_AUTH', false)
+ session[:using_admin] = 1
+ return
+ else
+ if session[:using_admin].nil?
+ if params[:emergency].nil?
+ if authenticated?(
+ :web => _("To log into the administrative interface"),
+ :email => _("Then you can log into the administrative interface"),
+ :email_subject => _("Log into the admin interface"),
+ :user_name => "a superuser")
+ if !@user.nil? && @user.admin_level == "super"
+ session[:using_admin] = 1
+ request.env['REMOTE_USER'] = @user.url_name
+ end
+ end
+ else
+ config_username = MySociety::Config.get('ADMIN_USERNAME', '')
+ config_password = MySociety::Config.get('ADMIN_PASSWORD', '')
+ authenticate_or_request_with_http_basic do |user_name, password|
+ if user_name == config_username && password == config_password
+ session[:using_admin] = 1
+ request.env['REMOTE_USER'] = user_name
+ else
+ request_http_basic_authentication
+ end
end
end
- else
- session[:using_admin] = 1
end
- end
+ end
+ end
end
diff --git a/app/controllers/admin_user_controller.rb b/app/controllers/admin_user_controller.rb
index b2c084739..249030537 100644
--- a/app/controllers/admin_user_controller.rb
+++ b/app/controllers/admin_user_controller.rb
@@ -74,10 +74,9 @@ class AdminUserController < AdminController
def login_as
@admin_user = User.find(params[:id]) # check user does exist
- post_redirect = PostRedirect.new( :uri => main_url(user_url(@admin_user)), :user_id => @admin_user.id)
+ post_redirect = PostRedirect.new( :uri => main_url(user_url(@admin_user)), :user_id => @admin_user.id, :circumstance => "login_as" )
post_redirect.save!
url = main_url(confirm_url(:email_token => post_redirect.email_token, :only_path => true))
- session[:user_id] = nil # Log out current (usually admin) user, so we get logged in as the other user
redirect_to url
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index b681f455d..0d0cca3e4 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# controllers/application.rb:
# Parent class of all controllers in FOI site. Filters added to this controller
# apply to all controllers in the application. Likewise, all the methods added
@@ -151,8 +152,8 @@ class ApplicationController < ActionController::Base
false
end
- # Called from test code, is a mimic of User.confirm, for use in following email
- # links when in controller tests (since we don't have full integration tests that
+ # Called from test code, is a mimic of UserController.confirm, for use in following email
+ # links when in controller tests (though we also have full integration tests that
# can work over multiple controllers)
def test_code_redirect_by_email_token(token, controller_example_group)
post_redirect = PostRedirect.find_by_email_token(token)
@@ -178,7 +179,7 @@ class ApplicationController < ActionController::Base
end
def foi_fragment_cache_path(param)
- path = File.join(RAILS_ROOT, 'cache', 'views', foi_fragment_cache_part_path(param))
+ path = File.join(Rails.root, 'cache', 'views', foi_fragment_cache_part_path(param))
max_file_length = 255 - 35 # we subtract 35 because tempfile
# adds on a variable number of
# characters
@@ -224,15 +225,15 @@ class ApplicationController < ActionController::Base
post_redirect = PostRedirect.new(:uri => request.request_uri, :post_params => params,
:reason_params => reason_params)
post_redirect.save!
- # 'modal' controls whether the sign-in form will be displayed in the typical full-blown
- # page or on its own, useful for pop-ups
+ # 'modal' controls whether the sign-in form will be displayed in the typical full-blown
+ # page or on its own, useful for pop-ups
redirect_to signin_url(:token => post_redirect.token, :modal => params[:modal])
return false
end
return true
end
- def authenticated_as_user?(user, reason_params)
+ def authenticated_as_user?(user, reason_params)
reason_params[:user_name] = user.name
reason_params[:user_url] = show_user_url(:url_name => user.url_name)
if session[:user_id]
@@ -274,6 +275,8 @@ class ApplicationController < ActionController::Base
# XXX what is the built in Ruby URI munging function that can do this
# choice of & vs. ? more elegantly than this dumb if statement?
if uri.include?("?")
+ # XXX This looks odd. What would a fragment identifier be doing server-side?
+ # But it also looks harmless, so I’ll leave it just in case.
if uri.include?("#")
uri.sub!("#", "&post_redirect=1#")
else
@@ -294,6 +297,7 @@ class ApplicationController < ActionController::Base
if params[:post_redirect] and session[:post_redirect_token]
post_redirect = PostRedirect.find_by_token(session[:post_redirect_token])
params.update(post_redirect.post_params)
+ params[:post_redirect_user] = post_redirect.user
end
end
@@ -540,16 +544,6 @@ class ApplicationController < ActionController::Base
return country
end
- def quietly_try_to_open(url)
- begin
- result = open(url).read.strip
- rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
- logger.warn("Unable to open third-party URL #{url}")
- result = ""
- end
- return result
- end
-
# URL generating functions are needed by all controllers (for redirects),
# views (for links) and mailers (for use in emails), so include them into
# all of all.
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 313a57d7d..36edab9fa 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# app/controllers/request_controller.rb:
# Show information about one particular request.
#
@@ -137,6 +138,8 @@ class RequestController < ApplicationController
@per_page = 25
@page = (params[:page] || "1").to_i
@info_request = InfoRequest.find_by_url_title(params[:url_title])
+ raise ActiveRecord::RecordNotFound.new("Request not found") if @info_request.nil?
+
if !@info_request.user_can_view?(authenticated_user)
render :template => 'request/hidden', :status => 410 # gone
return
@@ -146,7 +149,7 @@ class RequestController < ApplicationController
if (@page > 1)
@page_desc = " (page " + @page.to_s + ")"
- else
+ else
@page_desc = ""
end
end
@@ -168,7 +171,7 @@ class RequestController < ApplicationController
query = make_query_from_params
@title = _("View and search requests")
sortby = "newest"
- @cache_tag = Digest::MD5.hexdigest(query + @page.to_s)
+ @cache_tag = Digest::MD5.hexdigest(query + @page.to_s + I18n.locale.to_s)
behavior_cache :tag => [@cache_tag] do
xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
@list_results = xapian_object.results.map { |r| r[:model] }
@@ -344,7 +347,13 @@ class RequestController < ApplicationController
return
end
- @info_request.user = authenticated_user
+ if params[:post_redirect_user]
+ # If an admin has clicked the confirmation link on a users behalf,
+ # we don’t want to reassign the request to the administrator.
+ @info_request.user = params[:post_redirect_user]
+ else
+ @info_request.user = authenticated_user
+ end
# This automatically saves dependent objects, such as @outgoing_message, in the same transaction
@info_request.save!
# XXX send_message needs the database id, so we send after saving, which isn't ideal if the request broke here.
@@ -682,7 +691,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
@@ -837,7 +846,7 @@ class RequestController < ApplicationController
logger.error("Could not convert info request #{info_request.id} to PDF with command '#{convert_command} #{url} #{tempfile.path}'")
end
tempfile.close
- else
+ else
logger.warn("No HTML -> PDF converter found at #{convert_command}")
end
if !done
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index d858ab233..312cedc6c 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -50,11 +50,15 @@ class TrackController < ApplicationController
raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil?
# If found by historic name, or alternate locale name, redirect to new name
if @public_body.url_name != params[:url_name]
- redirect_to track_public_body_url(:url_name => @public_body.url_name, :feed => params[:feed])
+ redirect_to track_public_body_url(:url_name => @public_body.url_name, :feed => params[:feed], :event_type => params[:event_type])
return
end
- @track_thing = TrackThing.create_track_for_public_body(@public_body)
+ if params[:event_type]
+ @track_thing = TrackThing.create_track_for_public_body(@public_body, params[:event_type])
+ else
+ @track_thing = TrackThing.create_track_for_public_body(@public_body)
+ end
return atom_feed_internal if params[:feed] == 'feed'
@@ -94,7 +98,23 @@ class TrackController < ApplicationController
return atom_feed_internal if params[:feed] == 'feed'
if self.track_set
- redirect_to search_url(@query)
+ if @query.scan("variety").length == 1
+ # we're making a track for a simple filter, for which
+ # there's an expression in the UI (rather than relying
+ # on index:value strings in the query)
+ if @query =~ /variety:user/
+ postfix = "users"
+ @query.sub!("variety:user", "")
+ elsif @query =~ /variety:authority/
+ postfix = "bodies"
+ @query.sub!("variety:authority", "")
+ elsif @query =~ /variety:sent/
+ postfix = "requests"
+ @query.sub!("variety:sent", "")
+ end
+ @query.strip!
+ end
+ redirect_to search_url([@query, postfix])
end
end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 403cb9684..08726183e 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -182,7 +182,7 @@ class UserController < ApplicationController
return
end
- if !User.stay_logged_in_on_redirect?(@user)
+ if !User.stay_logged_in_on_redirect?(@user) || post_redirect.circumstance == "login_as"
@user = post_redirect.user
@user.email_confirmed = true
@user.save!
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 56c33e512..74c56dc8c 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -204,7 +204,9 @@ module LinkToHelper
# Basic date format
def simple_date(date)
- return I18n.l(date, :format => "%e %B %Y")
+ date_format = _("simple_date_format")
+ date_format = :long if date_format == "simple_date_format"
+ return I18n.l(date.to_date, :format => date_format)
end
def simple_time(date)
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index cbbcf5aa6..2896de68a 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -816,7 +816,6 @@ class IncomingMessage < ActiveRecord::Base
:filename => _get_part_file_name(leaf),
:charset => leaf.charset,
:within_rfc822_subject => within_rfc822_subject,
- :display_size => "0K",
:body => body)
attachment.save!
attachments << attachment.id
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index b5a1cd833..e570150bb 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -23,6 +23,9 @@
require 'digest/sha1'
class InfoRequest < ActiveRecord::Base
+ include ActionView::Helpers::UrlHelper
+ include ActionController::UrlWriter
+
strip_attributes!
validates_presence_of :title, :message => N_("Please enter a summary of your request")
@@ -453,7 +456,6 @@ public
# An annotation (comment) is made
def add_comment(body, user)
comment = Comment.new
-
ActiveRecord::Base.transaction do
comment.body = body
comment.user = user
@@ -1042,6 +1044,21 @@ public
end
return ret
end
+
+ before_save :purge_in_cache
+ def purge_in_cache
+ if !MySociety::Config.get('VARNISH_HOST').nil? && !self.id.nil?
+ # we only do this for existing info_requests (new ones have a nil id)
+ path = url_for(:controller => 'request', :action => 'show', :url_title => self.url_title, :only_path => true, :locale => :none)
+ req = PurgeRequest.find_by_url(path)
+ if req.nil?
+ req = PurgeRequest.new(:url => path,
+ :model => self.class.base_class.to_s,
+ :model_id => self.id)
+ end
+ req.save()
+ end
+ end
end
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 99f34cf9e..cb49596cb 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -36,25 +36,29 @@ class InfoRequestEvent < ActiveRecord::Base
has_many :track_things_sent_emails
validates_presence_of :event_type
- validates_inclusion_of :event_type, :in => [
- 'sent',
- 'resent',
- 'followup_sent',
- 'followup_resent',
-
- 'edit', # title etc. edited (in admin interface)
- 'edit_outgoing', # outgoing message edited (in admin interface)
- 'edit_comment', # comment edited (in admin interface)
- 'destroy_incoming', # deleted an incoming message (in admin interface)
- 'destroy_outgoing', # deleted an outgoing message (in admin interface)
- 'redeliver_incoming', # redelivered an incoming message elsewhere (in admin interface)
- 'move_request', # changed user or public body (in admin interface)
- 'manual', # you did something in the db by hand
-
- 'response',
- 'comment',
- 'status_update'
- ]
+
+ def self.enumerate_event_types
+ [
+ 'sent',
+ 'resent',
+ 'followup_sent',
+ 'followup_resent',
+
+ 'edit', # title etc. edited (in admin interface)
+ 'edit_outgoing', # outgoing message edited (in admin interface)
+ 'edit_comment', # comment edited (in admin interface)
+ 'destroy_incoming', # deleted an incoming message (in admin interface)
+ 'destroy_outgoing', # deleted an outgoing message (in admin interface)
+ 'redeliver_incoming', # redelivered an incoming message elsewhere (in admin interface)
+ 'move_request', # changed user or public body (in admin interface)
+ 'manual', # you did something in the db by hand
+
+ 'response',
+ 'comment',
+ 'status_update',
+ ]
+ end
+ validates_inclusion_of :event_type, :in => enumerate_event_types
# user described state (also update in info_request)
validate :must_be_valid_state
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index cc561b21d..de3c916aa 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -267,7 +267,10 @@ class OutgoingMessage < ActiveRecord::Base
end
end
-
+ after_save(:purge_in_cache)
+ def purge_in_cache
+ self.info_request.purge_in_cache
+ end
end
diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb
index 59cc86799..c9a6229a4 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -39,7 +39,7 @@ class PostRedirect < ActiveRecord::Base
self.post_params_yaml = params.to_yaml
end
def post_params
- if self.post_params_yaml.nil?
+ if self.post_params_yaml.nil?
return {}
end
YAML.load(self.post_params_yaml)
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb
index 43dbbbf0a..798094d90 100644
--- a/app/models/profile_photo.rb
+++ b/app/models/profile_photo.rb
@@ -17,8 +17,6 @@
#
# $Id: profile_photo.rb,v 1.2 2009-09-17 21:10:05 francis Exp $
#
-require 'mahoro'
-require 'RMagick'
class ProfilePhoto < ActiveRecord::Base
WIDTH = 96
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 961fa3cbb..54af547bd 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -240,7 +240,7 @@ class PublicBody < ActiveRecord::Base
# Return the short name if present, or else long name
def short_or_long_name
if self.short_name.nil? || self.short_name.empty? # 'nil' can happen during construction
- self.name
+ self.name.nil? ? "" : self.name
else
self.short_name
end
@@ -282,19 +282,11 @@ class PublicBody < ActiveRecord::Base
# Guess home page from the request email, or use explicit override, or nil
# if not known.
def calculated_home_page
- # manual override for ones we calculate wrongly
- if self.home_page != ''
- return self.home_page
+ if home_page && !home_page.empty?
+ home_page[URI::regexp(%w(http https))] ? home_page : "http://#{home_page}"
+ elsif request_email_domain
+ "http://www.#{request_email_domain}"
end
-
- # extract the domain name from the FOI request email
- url = self.request_email_domain
- if url.nil?
- return nil
- end
-
- # add standard URL prefix
- return "http://www." + url
end
# Are all requests to this body under the Environmental Information Regulations?
@@ -527,7 +519,7 @@ class PublicBody < ActiveRecord::Base
end
def has_notes?
- return self.notes != ""
+ return !self.notes.nil? && self.notes != ""
end
def notes_as_html
self.notes
@@ -555,6 +547,11 @@ class PublicBody < ActiveRecord::Base
}
end
+ after_save(:purge_in_cache)
+ def purge_in_cache
+ self.info_requests.each {|x| x.purge_in_cache}
+ end
+
end
diff --git a/app/models/purge_request.rb b/app/models/purge_request.rb
new file mode 100644
index 000000000..088d5b84b
--- /dev/null
+++ b/app/models/purge_request.rb
@@ -0,0 +1,39 @@
+# models/purge_request.rb:
+# A queue of URLs to purge
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+#
+
+class PurgeRequest < ActiveRecord::Base
+ def self.purge_all
+ done_something = false
+ for item in PurgeRequest.all()
+ item.purge
+ done_something = true
+ end
+ return done_something
+ end
+
+ def self.purge_all_loop
+ # Run purge_all in an endless loop, sleeping when there is nothing to do
+ while true
+ sleep_seconds = 1
+ while !purge_all
+ sleep sleep_seconds
+ sleep_seconds *= 2
+ sleep_seconds = 30 if sleep_seconds > 30
+ end
+ end
+ end
+
+ def purge
+ config = MySociety::Config.load_default()
+ varnish_url = config['VARNISH_HOST']
+ result = quietly_try_to_purge(varnish_url, self.url)
+ self.delete()
+ end
+end
+
+
+
diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb
index 3e12a6feb..1feb9c70b 100644
--- a/app/models/raw_email.rb
+++ b/app/models/raw_email.rb
@@ -27,7 +27,7 @@ class RawEmail < ActiveRecord::Base
def directory
request_id = self.incoming_message.info_request.id.to_s
if ENV["RAILS_ENV"] == "test"
- return File.join(RAILS_ROOT, 'files/raw_email_test')
+ return File.join(Rails.root, 'files/raw_email_test')
else
return File.join(MySociety::Config.get('RAW_EMAILS_LOCATION',
'files/raw_emails'),
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb
index 83cce9045..177a39241 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -40,7 +40,7 @@ class RequestMailer < ApplicationMailer
:filename => "original.eml", :transfer_encoding => '7bit', :content_disposition => 'inline'
@body = {
:info_request => info_request,
- :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost')
+ :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost')
}
end
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index 58d70ed86..bdcd87e4f 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -108,7 +108,7 @@ class TrackThing < ActiveRecord::Base
end
descriptions = []
if varieties.include? _("requests")
- descriptions << _("requests which are {{list_of_statuses}}", :list_of_statuses => Array(statuses).join(_(' or ')))
+ descriptions << _("requests which are {{list_of_statuses}}", :list_of_statuses => Array(statuses).sort.join(_(' or ')))
varieties -= [_("requests")]
end
if descriptions.empty? and varieties.empty?
@@ -116,7 +116,7 @@ class TrackThing < ActiveRecord::Base
end
descriptions += Array(varieties)
parsed_text = parsed_text.strip
- descriptions = descriptions.join(_(" or "))
+ descriptions = descriptions.sort.join(_(" or "))
if !parsed_text.empty?
descriptions += _("{{list_of_things}} matching text '{{search_query}}'", :list_of_things => "", :search_query => parsed_text)
end
@@ -146,11 +146,15 @@ class TrackThing < ActiveRecord::Base
return track_thing
end
- def TrackThing.create_track_for_public_body(public_body)
+ def TrackThing.create_track_for_public_body(public_body, event_type = nil)
track_thing = TrackThing.new
track_thing.track_type = 'public_body_updates'
track_thing.public_body = public_body
- track_thing.track_query = "requested_from:" + public_body.url_name
+ query = "requested_from:" + public_body.url_name
+ if InfoRequestEvent.enumerate_event_types.include?(event_type)
+ query += " variety:" + event_type
+ end
+ track_thing.track_query = query
return track_thing
end
@@ -171,10 +175,10 @@ class TrackThing < ActiveRecord::Base
query += " variety:sent"
when "users"
query += " variety:user"
- when "authorities"
- query += " variety:authority"
+ when "bodies"
+ query += " variety:authority"
end
- end
+ end
track_thing.track_query = query
# XXX should extract requested_by:, request:, requested_from:
# and stick their values into the respective relations.
diff --git a/app/models/user.rb b/app/models/user.rb
index 59a84b7aa..73d65a8ca 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -422,5 +422,12 @@ class User < ActiveRecord::Base
end
return true
end
+
+ 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}
+ end
+
end
diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml
index 90ace809e..a1f8c8f04 100644
--- a/app/views/general/search.rhtml
+++ b/app/views/general/search.rhtml
@@ -131,8 +131,7 @@
</p>
<% end %>
</div> <!-- header left -->
-
-<% if @track_thing && (@xapian_bodies_hits > 0 || @xapian_users_hits > 0 || @total_hits == 0)%>
+<% if !@track_thing.nil? %>
<div id="header_right">
<h2><%= _('Track this search')%></h2>
<%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'main' } %>
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index c5d040fb7..611704ebe 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -1,4 +1,6 @@
-<% @title = "#{h(@info_request.title)} - a Freedom of Information request to #{h(@info_request.public_body.name)}" %>
+<% @title = _("{{title}} - a Freedom of Information request to {{public_body}}",
+ :title => h(@info_request.title),
+ :public_body => (@info_request.public_body.name)) %>
<% if @info_request.prominence == 'hidden' %>
<p id="hidden_request">
diff --git a/app/views/user/confirm.rhtml b/app/views/user/confirm.rhtml
index bdaf5c8e9..bc70a1f36 100644
--- a/app/views/user/confirm.rhtml
+++ b/app/views/user/confirm.rhtml
@@ -1,6 +1,6 @@
-<% @title = h("Now check your email!") %>
+<% @title = _("Now check your email!") %>
-<h1 class="confirmation_heading">Now check your email!</h1>
+<h1 class="confirmation_heading"><%= _("Now check your email!") %></h1>
<p class="confirmation_message">
<%= _('We\'ve sent you an email, and you\'ll need to click the link in it before you can
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 8f1803442..f8b820f03 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -1,7 +1,7 @@
<% if @show_requests %>
- <% @title = h(@display_user.name) + " - Freedom of Information requests" %>
+ <% @title = h(@display_user.name) + _(" - Freedom of Information requests") %>
<% else %>
- <% @title = h(@display_user.name) + " - user profile" %>
+ <% @title = h(@display_user.name) + _(" - user profile") %>
<% end %>
<% if (@same_name_users.size >= 1) %>
@@ -139,7 +139,7 @@
<% if !@xapian_requests.nil? %>
<% if @xapian_requests.results.empty? %>
<% if @page == 1 %>
- <h2 class="foi_results" id="foi_requests"><%= @is_you ? 'Freedom of Information requests made by you' : 'Freedom of Information requests made by this person' %> <%= @match_phrase %>
+ <h2 class="foi_results" id="foi_requests"><%= @is_you ? _('Freedom of Information requests made by you') : _('Freedom of Information requests made by this person') %> <%= @match_phrase %>
</h2>
<p><%= @is_you ? _('You have made no Freedom of Information requests using this site.') : _('This person has made no Freedom of Information requests using this site.') %>
<%= @page_desc %>
diff --git a/app/views/user/sign.rhtml b/app/views/user/sign.rhtml
index bfd0fa63e..4704ea95a 100644
--- a/app/views/user/sign.rhtml
+++ b/app/views/user/sign.rhtml
@@ -10,7 +10,10 @@
<%= @post_redirect.reason_params[:web] %>,
<%= _('please sign in as ')%><%= link_to h(@post_redirect.reason_params[:user_name]), @post_redirect.reason_params[:user_url] %>.
<% end %>
- </p>
+ </p>
+ <% if @post_redirect.post_params["controller"] == "admin_general" %>
+ <p id="superuser_message">Don't have a superuser account yet? <%= link_to "Sign in as the emergency user", @post_redirect.uri + "?emergency=1" %></p>
+ <% end %>
<%= render :partial => 'signin', :locals => { :sign_in_as_existing_user => true } %>