diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_public_body_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 28 | ||||
-rw-r--r-- | app/models/public_body.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/views/admin_public_body/import_csv.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/new.rhtml | 4 | ||||
-rw-r--r-- | app/views/user/rate_limited.rhtml | 14 |
9 files changed, 56 insertions, 19 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index c6904da95..bf7c07905 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -56,7 +56,7 @@ class AdminPublicBodyController < AdminController flash[:notice] = "Added tag to table of bodies." end - redirect_to admin_url('body/list') + "?query=" + @query + (@page.nil? ? "" : "&page=" + @page) # XXX construct this URL properly + redirect_to admin_body_list_url(:query => @query, :page => @page) end def missing_scheme @@ -127,14 +127,14 @@ class AdminPublicBodyController < AdminController if public_body.info_requests.size > 0 flash[:notice] = "There are requests associated with the authority, so can't destroy it" - redirect_to admin_url('body/show/' + public_body.id.to_s) + redirect_to admin_body_show_url(public_body) return end public_body.tag_string = "" public_body.destroy flash[:notice] = "PublicBody was successfully destroyed." - redirect_to admin_url('body/list') + redirect_to admin_body_list_url end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1849f23f3..b681f455d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -363,7 +363,10 @@ class ApplicationController < ActionController::Base else @page = this_page end - return InfoRequest.full_search(models, @query, order, ascending, collapse, @per_page, @page) + result = InfoRequest.full_search(models, @query, order, ascending, collapse, @per_page, @page) + result.results # Touch the results to load them, otherwise accessing them from the view + # might fail later if the database has subsequently been reopened. + return result end def get_search_page_from_params return (params[:page] || "1").to_i diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 659433c9e..00d1cc1e0 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # app/controllers/public_body_controller.rb: # Show information about a public body. # @@ -117,14 +118,17 @@ class PublicBodyController < ApplicationController and has_tag_string_tags.model = \'PublicBody\' and has_tag_string_tags.name = ?) > 0', @query, @query, default_locale, @tag] end + if @tag == "all" @description = "" elsif @tag.size == 1 - @description = _("beginning with") + " '" + @tag + "'" + @description = _("beginning with ‘{{first_letter}}’", :first_letter=>@tag) else - @description = PublicBodyCategories::get().by_tag()[@tag] - if @description.nil? - @description = @tag + category_name = PublicBodyCategories::get().by_tag()[@tag] + if category_name.nil? + @description = _("matching the tag ‘{{tag_name}}’", :tag_name=>@tag) + else + @description = _("in the category ‘{{category_name}}’", :category_name=>category_name) end end PublicBody.with_locale(@locale) do diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index fc1ffdd75..2295d6718 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -207,18 +207,28 @@ class RequestController < ApplicationController end # Banned from making new requests? + user_exceeded_limit = false if !authenticated_user.nil? && !authenticated_user.can_file_requests? - if authenticated_user.exceeded_limit? - render :template => 'user/rate_limited' - else + # If the reason the user cannot make new requests is that they are + # rate-limited, it’s possible they composed a request before they + # logged in and we want to include the text of the request so they + # can squirrel it away for tomorrow, so we detect this later after + # we have constructed the InfoRequest. + user_exceeded_limit = authenticated_user.exceeded_limit? + if !user_exceeded_limit @details = authenticated_user.can_fail_html render :template => 'user/banned' + return end - return end # First time we get to the page, just display it if params[:submitted_new_request].nil? || params[:reedit] + if user_exceeded_limit + render :template => 'user/rate_limited' + return + end + params[:info_request] = { } if !params[:info_request] # Read parameters in - first the public body (by URL name or id) @@ -318,6 +328,11 @@ class RequestController < ApplicationController return end + if user_exceeded_limit + render :template => 'user/rate_limited' + return + end + if !authenticated?( :web => _("To send your FOI request"), :email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name), @@ -701,7 +716,10 @@ class RequestController < ApplicationController @incoming_message.parse_raw_email! @info_request = @incoming_message.info_request if @incoming_message.info_request_id != params[:id].to_i - message = "Incoming message %d does not belong to request %d" % [@incoming_message.info_request_id, params[:id]] + # Note that params[:id] might not be an integer, though + # if we’ve got this far then it must begin with an integer + # and that integer must be the id number of an actual request. + message = "Incoming message %d does not belong to request '%s'" % [@incoming_message.info_request_id, params[:id]] raise ActiveRecord::RecordNotFound.new(message) end @part_number = params[:part].to_i diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 453e3a6cf..9ac668b10 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -275,7 +275,7 @@ class PublicBody < ActiveRecord::Base ret = ret + types[-1] return ret else - return "A public authority" + return _("A public authority") end end diff --git a/app/models/user.rb b/app/models/user.rb index 2193805ea..8c4b35fe6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -132,7 +132,7 @@ class User < ActiveRecord::Base name.strip! end if self.public_banned? - name = _("{{user_name}} (Banned)", :user_name=>name) + name = _("{{user_name}} (Account suspended)", :user_name=>name) end name end diff --git a/app/views/admin_public_body/import_csv.rhtml b/app/views/admin_public_body/import_csv.rhtml index ecd2c38b7..d5717de23 100644 --- a/app/views/admin_public_body/import_csv.rhtml +++ b/app/views/admin_public_body/import_csv.rhtml @@ -31,7 +31,7 @@ <p><strong>CSV file format:</strong> A first row with the list of fields, starting with '#', is optional but highly recommended. The fields 'name' - and 'request_email' are required; additionaly, translated values are supported by + and 'request_email' are required; additionally, translated values are supported by adding the locale name to the field name, e.g. 'name.es', 'name.de'... Example: </p> diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml index 2e554a20b..23212fc0b 100644 --- a/app/views/request/new.rhtml +++ b/app/views/request/new.rhtml @@ -47,12 +47,12 @@ <% end %> </div> - <div id="request_header_text"> <% if @info_request.public_body.has_notes? %> + <div id="request_header_text"> <h3><%= _('Special note for this authority!') %></h3> <p><%= @info_request.public_body.notes_as_html %></p> + </div> <% end %> - </div> <% if @info_request.public_body.eir_only? %> <h3><%= _('Please ask for environmental information only') %></h3> diff --git a/app/views/user/rate_limited.rhtml b/app/views/user/rate_limited.rhtml index d513cec9e..c1e8f360e 100644 --- a/app/views/user/rate_limited.rhtml +++ b/app/views/user/rate_limited.rhtml @@ -2,4 +2,16 @@ <h1><%=@title%></h1> -<p><%= _('You have made too many requests today. Please try again tomorrow.')%></p> +<p><%= _("There is a limit on the number of requests that you can make in any one day. You can make more requests tomorrow.")%></p> + +<!-- Insert explanation of why we have a limit --> + +<p><%= _("If you need to make more requests than this, <a href='%s'>get in touch</a> and we’ll consider it.") % [help_contact_path] %></p> + +<% if @info_request %> + <p><%= _("Here is the message you wrote, in case you would like to copy the text and save it for later.") %></p> + + <div class="correspondence"> + <div class="correspondence_text"><%= @info_request.outgoing_messages[0].get_body_for_html_display %></div> + </div> +<% end %> |