aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_controller.rb14
-rw-r--r--app/controllers/application_controller.rb14
-rw-r--r--app/controllers/general_controller.rb8
-rw-r--r--app/controllers/public_body_controller.rb9
-rw-r--r--app/controllers/request_controller.rb7
5 files changed, 22 insertions, 30 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 655670b5a..0bfbcd3d1 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -45,13 +45,17 @@ class AdminController < ApplicationController
end
end
private
+
def authenticate
- username = MySociety::Config.get('ADMIN_USERNAME', '')
- password = MySociety::Config.get('ADMIN_PASSWORD', '')
- if !username.empty? && !password.empty?
+ 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|
- user_name == username && password == password
- session[:using_admin] = 1
+ if user_name == config_username && password == config_password
+ session[:using_admin] = 1
+ else
+ request_http_basic_authentication
+ end
end
else
session[:using_admin] = 1
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 239145944..b7457c48e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -488,20 +488,6 @@ class ApplicationController < ActionController::Base
# Site-wide access to configuration settings
include ConfigHelper
-
- # XXX: patch to improve usability of gettext's _(), which by default accepts only
- # one parameter. This is normally done in a monkey patch file named 'i18n_fixes.rb'.
- # For some reason - and only when running in production -, after adding a new controller
- # in a theme, the monkey patch in 'i18n_fixes.rb' doesn't seem to take effect.
- # But it works just fine in the views.
- # It's probably related to the loading order of classes, but including the
- # monkey patch before or after the theme makes no difference. Even more bizarrely,
- # require'ing or load'ing the patch file here doesn't work (!?), I need to redefine
- # the method explicitely. I'm going crazy...
- def _(key, options = {})
- translation = FastGettext._(key) || key
- gettext_interpolate(translation, options)
- end
end
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 55abea3b7..194a1cec0 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -70,13 +70,13 @@ class GeneralController < ApplicationController
def blog
medium_cache
@feed_autodetect = []
- feed_url = MySociety::Config.get('BLOG_FEED', '')
- if not feed_url.empty?
- content = open(feed_url).read
+ @feed_url = "#{MySociety::Config.get('BLOG_FEED', '')}?lang=#{self.locale_from_params()}"
+ if not @feed_url.empty?
+ content = open(@feed_url).read
@data = XmlSimple.xml_in(content)
@channel = @data['channel'][0]
@blog_items = @channel['item']
- @feed_autodetect = [{:url => feed_url, :title => "#{site_name} blog"}]
+ @feed_autodetect = [{:url => @feed_url, :title => "#{site_name} blog"}]
else
@blog_items = []
end
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index e4f8753af..251ab5efe 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -19,7 +19,7 @@ class PublicBodyController < ApplicationController
@locale = self.locale_from_params()
PublicBody.with_locale(@locale) do
@public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
- raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? # XXX proper 404
+ raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil?
if @public_body.url_name.nil?
redirect_to :back
return
@@ -69,8 +69,9 @@ class PublicBodyController < ApplicationController
end
def view_email
- @public_bodies = PublicBody.find(:all, :conditions => [ "url_name = ?", params[:url_name] ])
- @public_body = @public_bodies[0]
+ @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
+ raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil?
+
PublicBody.with_locale(self.locale_from_params()) do
if params[:submitted_view_email]
if verify_recaptcha
@@ -187,7 +188,7 @@ class PublicBodyController < ApplicationController
query = params[:q] + '*'
query = query.split(' ').join(' OR ') # XXX: HACK for OR instead of default AND!
- @xapian_requests = perform_search([PublicBody], query, 'relevant', 'request_collapse', 5)
+ @xapian_requests = perform_search([PublicBody], query, 'relevant', nil, 5)
render :partial => "public_body/search_ahead"
end
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 06d8f15f4..4b7884065 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -39,7 +39,7 @@ class RequestController < ApplicationController
if !params[:query].nil?
query = params[:query] + '*'
query = query.split(' ').join(' OR ') # XXX: HACK for OR instead of default AND!
- @xapian_requests = perform_search([PublicBody], query, 'relevant', 'request_collapse', 5)
+ @xapian_requests = perform_search([PublicBody], query, 'relevant', nil, 5)
end
medium_cache
end
@@ -314,10 +314,11 @@ class RequestController < ApplicationController
# XXX send_message needs the database id, so we send after saving, which isn't ideal if the request broke here.
@outgoing_message.send_message
flash[:notice] = _("<p>Your {{law_used_full}} request has been <strong>sent on its way</strong>!</p>
- <p><strong>We will email you</strong> when there is a response, or after 20 working days if the authority still hasn't
+ <p><strong>We will email you</strong> when there is a response, or after {{late_number_of_days}} working days if the authority still hasn't
replied by then.</p>
<p>If you write about this request (for example in a forum or a blog) please link to this page, and add an
- annotation below telling people about your writing.</p>",:law_used_full=>@info_request.law_used_full)
+ annotation below telling people about your writing.</p>",:law_used_full=>@info_request.law_used_full,
+ :late_number_of_days => MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20))
redirect_to show_new_request_path(:url_title => @info_request.url_title)
end