aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_request_controller.rb8
-rw-r--r--app/controllers/api_controller.rb2
-rw-r--r--app/controllers/general_controller.rb1
-rw-r--r--app/controllers/request_controller.rb18
-rw-r--r--app/controllers/user_controller.rb4
-rw-r--r--app/models/incoming_message.rb4
-rw-r--r--app/models/info_request.rb52
-rw-r--r--app/views/admin_general/timeline.html.erb2
-rw-r--r--app/views/admin_public_body/import_csv.html.erb4
-rw-r--r--app/views/general/_locale_switcher.html.erb2
-rw-r--r--app/views/layouts/default.html.erb2
-rw-r--r--app/views/public_body/_alphabet.html.erb2
-rw-r--r--app/views/public_body/_body_listing_single.html.erb10
-rw-r--r--app/views/public_body/show.html.erb43
-rw-r--r--app/views/request/_sidebar.html.erb2
-rw-r--r--app/views/request/new.html.erb2
-rw-r--r--app/views/request/similar.html.erb15
17 files changed, 110 insertions, 63 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 66989ea93..40ccfb98c 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -62,9 +62,6 @@ class AdminRequestController < AdminController
@info_request.title = params[:info_request][:title]
@info_request.prominence = params[:info_request][:prominence]
- if @info_request.described_state != params[:info_request][:described_state]
- @info_request.set_described_state(params[:info_request][:described_state])
- end
@info_request.awaiting_description = params[:info_request][:awaiting_description] == "true" ? true : false
@info_request.allow_new_responses_from = params[:info_request][:allow_new_responses_from]
@info_request.handle_rejected_responses = params[:info_request][:handle_rejected_responses]
@@ -77,13 +74,16 @@ class AdminRequestController < AdminController
{ :editor => admin_current_user(),
:old_title => old_title, :title => @info_request.title,
:old_prominence => old_prominence, :prominence => @info_request.prominence,
- :old_described_state => old_described_state, :described_state => @info_request.described_state,
+ :old_described_state => old_described_state, :described_state => params[:info_request][:described_state],
:old_awaiting_description => old_awaiting_description, :awaiting_description => @info_request.awaiting_description,
:old_allow_new_responses_from => old_allow_new_responses_from, :allow_new_responses_from => @info_request.allow_new_responses_from,
:old_handle_rejected_responses => old_handle_rejected_responses, :handle_rejected_responses => @info_request.handle_rejected_responses,
:old_tag_string => old_tag_string, :tag_string => @info_request.tag_string,
:old_comments_allowed => old_comments_allowed, :comments_allowed => @info_request.comments_allowed
})
+ if @info_request.described_state != params[:info_request][:described_state]
+ @info_request.set_described_state(params[:info_request][:described_state])
+ end
# expire cached files
expire_for_request(@info_request)
flash[:notice] = 'Request successfully updated.'
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 49b226e4b..e7bea67ef 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -63,6 +63,8 @@ class ApiController < ApplicationController
:smtp_message_id => nil
)
+ request.set_described_state('waiting_response')
+
# Return the URL and ID number.
render :json => {
'url' => make_url("request", request.url_title),
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 939dd1739..540f67ec9 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -147,7 +147,6 @@ class GeneralController < ApplicationController
@query, _ = make_query_from_params(params)
end
@inputted_sortby = @sortby
- @common_query = get_tags_from_params(params)
if @sortby.nil?
# Parse query, so can work out if it has prefix terms only - if so then it is a
# structured query which should show newest first, rather than a free text search
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 42693f867..45d8b7de6 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -150,12 +150,6 @@ class RequestController < ApplicationController
:offset => (@page - 1) * @per_page, :limit => @per_page, :collapse_by_prefix => 'request_collapse')
@matches_estimated = @xapian_object.matches_estimated
@show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated
-
- if (@page > 1)
- @page_desc = " (page " + @page.to_s + ")"
- else
- @page_desc = ""
- end
end
def list
@@ -417,12 +411,22 @@ class RequestController < ApplicationController
end
# Make the state change
+ event = info_request.log_event("status_update",
+ { :user_id => authenticated_user.id,
+ :old_described_state => info_request.described_state,
+ :described_state => described_state,
+ })
+
info_request.set_described_state(described_state, authenticated_user, message)
# If you're not the *actual* requester. e.g. you are playing the
# classification game, or you're doing this just because you are an
# admin user (not because you also own the request).
if !info_request.is_actual_owning_user?(authenticated_user)
+ # Create a classification event for league tables
+ RequestClassification.create!(:user_id => authenticated_user.id,
+ :info_request_event_id => event.id)
+
# Don't give advice on what to do next, as it isn't their request
if session[:request_game]
flash[:notice] = _('Thank you for updating the status of the request \'<a href="{{url}}">{{info_request_title}}</a>\'. There are some more requests below for you to classify.',:info_request_title=>CGI.escapeHTML(info_request.title), :url=>CGI.escapeHTML(request_path(info_request)))
@@ -589,7 +593,7 @@ class RequestController < ApplicationController
@outgoing_message.set_signature_name(@user.name) if !@user.nil?
if (not @incoming_message.nil?) and @info_request != @incoming_message.info_request
- raise sprintf("Incoming message %d does not belong to request %d", @incoming_message.info_request_id, @info_request.id)
+ raise ActiveRecord::RecordNotFound.new("Incoming message #{@incoming_message.id} does not belong to request #{@info_request.id}")
end
# Test for hidden requests
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 1bf5a5316..175425280 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -19,8 +19,8 @@ class UserController < ApplicationController
# Show page about a user
def show
long_cache
- if MySociety::Format.simplify_url_part(params[:url_name], 'user', 32) != params[:url_name]
- redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'user', 32), :status => :moved_permanently
+ if MySociety::Format.simplify_url_part(params[:url_name], 'user') != params[:url_name]
+ redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'user'), :status => :moved_permanently
return
end
if params[:view].nil?
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 4910d43f4..ae3c3b407 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -258,7 +258,7 @@ class IncomingMessage < ActiveRecord::Base
# Used by binary_mask_stuff - replace text in place
def _binary_mask_stuff_internal!(text)
# Keep original size, so can check haven't resized it
- orig_size = text.size
+ orig_size = text.mb_chars.size
# Replace ASCII email addresses...
text.gsub!(MySociety::Validate.email_find_regexp) do |email|
@@ -293,7 +293,7 @@ class IncomingMessage < ActiveRecord::Base
# Replace censor items
self.info_request.apply_censor_rules_to_binary!(text)
- raise "internal error in binary_mask_stuff" if text.size != orig_size
+ raise "internal error in binary_mask_stuff" if text.mb_chars.size != orig_size
return text
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 46c247fa9..9bce2ca88 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -563,12 +563,15 @@ public
end
# change status, including for last event for later historical purposes
+ # described_state should always indicate the current state of the request, as described
+ # by the request owner (or, in some other cases an admin or other user)
def set_described_state(new_state, set_by = nil, message = "")
old_described_state = described_state
ActiveRecord::Base.transaction do
self.awaiting_description = false
last_event = self.info_request_events.last
last_event.described_state = new_state
+
self.described_state = new_state
last_event.save!
self.save!
@@ -584,25 +587,18 @@ public
end
unless set_by.nil? || is_actual_owning_user?(set_by) || described_state == 'attention_requested'
- # Log the status change by someone other than the requester
- event = log_event("status_update",
- { :user_id => set_by.id,
- :old_described_state => old_described_state,
- :described_state => described_state,
- })
- # Create a classification event for league tables
- RequestClassification.create!(:user_id => set_by.id,
- :info_request_event_id => event.id)
-
RequestMailer.old_unclassified_updated(self).deliver if !is_external?
end
end
- # Work out what the situation of the request is. In addition to values of
- # self.described_state, can take these two values:
+ # Work out what state to display for the request on the site. In addition to values of
+ # self.described_state, can take these values:
# waiting_classification
# waiting_response_overdue
# waiting_response_very_overdue
+ # (this method adds an assessment of overdueness with respect to the current time to 'waiting_response'
+ # states, and will return 'waiting_classification' instead of the described_state if the
+ # awaiting_description flag is set on the request).
def calculate_status(cached_value_ok=false)
if cached_value_ok && @cached_calculated_status
return @cached_calculated_status
@@ -621,10 +617,22 @@ public
return 'waiting_response'
end
+
+ # 'described_state' can be populated on any info_request_event but is only
+ # ever used in the process populating calculated_state on the
+ # info_request_event (if it represents a response, outgoing message, edit
+ # or status update), or previous response or outgoing message events for
+ # the same request.
+
# Fill in any missing event states for first response before a description
# was made. i.e. We take the last described state in between two responses
# (inclusive of earlier), and set it as calculated value for the earlier
- # response.
+ # response. Also set the calculated state for any initial outgoing message,
+ # follow up, edit or status_update to the described state of that event.
+
+ # Note that the calculated state of the latest info_request_event will
+ # be used in latest_status based searches and should match the described_state
+ # of the info_request.
def calculate_event_states
curr_state = nil
for event in self.info_request_events.reverse
@@ -658,10 +666,22 @@ public
event.save!
end
- # And we don't want to propogate it to the response itself,
+ # And we don't want to propagate it to the response itself,
# as that might already be set to waiting_clarification / a
# success status, which we want to know about.
curr_state = nil
+ elsif !curr_state.nil? && (['edit', 'status_update'].include? event.event_type)
+ # A status update or edit event should get the same calculated state as described state
+ # so that the described state is always indexed (and will be the latest_status
+ # for the request immediately after it has been described, regardless of what
+ # other request events precede it). This means that request should be correctly included
+ # in status searches for that status. These events allow the described state to propagate in
+ # case there is a preceding response that the described state should be applied to.
+ if event.calculated_state != event.described_state
+ event.calculated_state = event.described_state
+ event.last_described_at = Time.now()
+ event.save!
+ end
end
end
end
@@ -1117,10 +1137,10 @@ public
begin
if self.described_state.nil?
self.described_state = 'waiting_response'
- end
+ end
rescue ActiveModel::MissingAttributeError
# this should only happen on Model.exists?() call. It can be safely ignored.
- # See http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/
+ # See http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/
end
# FOI or EIR?
if !self.public_body.nil? && self.public_body.eir_only?
diff --git a/app/views/admin_general/timeline.html.erb b/app/views/admin_general/timeline.html.erb
index 8fd8875b6..439ae1e68 100644
--- a/app/views/admin_general/timeline.html.erb
+++ b/app/views/admin_general/timeline.html.erb
@@ -88,7 +88,7 @@
<% elsif event.event_type == 'comment' %>
had an annotation posted by <%=h event.comment.user.name %>.
<% elsif event.event_type == 'status_update' %>
- had its status updated by <%=h User.find(event.params[:user_id]).name %> from '<%= h event.params[:old_described_state] %>' to '<%= h event.params[:described_state] %>'.
+ had its status updated by <%= event.params[:user_id] ? User.find(event.params[:user_id]).name : event.params[:script] %> from '<%= h event.params[:old_described_state] %>' to '<%= h event.params[:described_state] %>'.
<% else %>
had '<%=event.event_type%>' done to it, parameters <%=h event.params_yaml%>.
<% end %>
diff --git a/app/views/admin_public_body/import_csv.html.erb b/app/views/admin_public_body/import_csv.html.erb
index afda5a468..18341ecf1 100644
--- a/app/views/admin_public_body/import_csv.html.erb
+++ b/app/views/admin_public_body/import_csv.html.erb
@@ -31,8 +31,8 @@
<p>
<label for="tag_behaviour">What to do with existing tags?</label>
<%= select_tag 'tag_behaviour',
- "<option value='add' selected>Add new tags to existing ones</option>
- <option value='replace'>Replace existing tags with new ones</option>"
+ raw("<option value='add' selected>Add new tags to existing ones</option>
+ <option value='replace'>Replace existing tags with new ones</option>")
%>
</p>
diff --git a/app/views/general/_locale_switcher.html.erb b/app/views/general/_locale_switcher.html.erb
index d0040bb0d..a318f61f3 100644
--- a/app/views/general/_locale_switcher.html.erb
+++ b/app/views/general/_locale_switcher.html.erb
@@ -2,7 +2,7 @@
<div id="user_locale_switcher">
<div class="btn-group">
<% for possible_locale in FastGettext.default_available_locales %>
- <% if possible_locale == I18n.locale.to_s %>
+ <% if possible_locale == FastGettext.locale %>
<a href="#" class="btn disabled"><%= locale_name(possible_locale) %></a>
<% else %>
<a href="<%= url_for params.merge(:locale => possible_locale) %>" class="btn"><%= locale_name(possible_locale) %></a>
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb
index 688816fa9..472fa8ec1 100644
--- a/app/views/layouts/default.html.erb
+++ b/app/views/layouts/default.html.erb
@@ -52,7 +52,7 @@
'width': 920,
'height': 400,
'type': 'iframe',
- 'href': '/<%= I18n.locale %>/profile/sign_in?modal=1',
+ 'href': '/<%= FastGettext.locale %>/profile/sign_in?modal=1',
'onClosed': function() {
// modal_signin_successful variable set by modal dialog box
if (typeof modal_signin_successful != 'undefined' ) {
diff --git a/app/views/public_body/_alphabet.html.erb b/app/views/public_body/_alphabet.html.erb
index 111da5b3b..63b24e0fb 100644
--- a/app/views/public_body/_alphabet.html.erb
+++ b/app/views/public_body/_alphabet.html.erb
@@ -1,3 +1,3 @@
-<%= "A".upto("Z") do |l| -%>
+<%- "A".upto("Z") do |l| -%>
<%= link_to_unless (@tag == l), l, list_public_bodies_path(:tag => l.downcase) %>
<% end %>
diff --git a/app/views/public_body/_body_listing_single.html.erb b/app/views/public_body/_body_listing_single.html.erb
index 8e0a64df7..91a07d09c 100644
--- a/app/views/public_body/_body_listing_single.html.erb
+++ b/app/views/public_body/_body_listing_single.html.erb
@@ -20,8 +20,14 @@
<span class="bottomline">
<%= n_('{{count}} request made.', '{{count}} requests made.', public_body.info_requests.size,
:count => public_body.info_requests.size) %>
- <% if !@include_request_link_in_authority_listing.nil? %>
- <%= link_to _("Make your own request"), public_body_path(public_body) %>.
+ <% if !public_body.is_requestable? && public_body.not_requestable_reason != 'bad_contact' %>
+ <% if public_body.not_requestable_reason == 'defunct' %>
+ <%= _('Defunct.') %>
+ <% end %>
+ <% else %>
+ <% if !@include_request_link_in_authority_listing.nil? %>
+ <%= link_to _("Make your own request"), public_body_path(public_body) %>.
+ <% end %>
<% end %>
<br>
<span class="date_added">
diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb
index 47075a1f5..b35e29eea 100644
--- a/app/views/public_body/show.html.erb
+++ b/app/views/public_body/show.html.erb
@@ -46,12 +46,22 @@
<% end %>
</p>
- <% if @public_body.has_notes? && (@public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact') %>
- <p><%= @public_body.notes_as_html.html_safe %></p>
- <% end %>
-
- <% if @public_body.eir_only? %>
- <p><%= _('You can only request information about the environment from this authority.')%></p>
+ <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
+ <% if @public_body.has_notes? %>
+ <p><%= @public_body.notes_as_html.html_safe %></p>
+ <% end %>
+ <% if @public_body.eir_only? %>
+ <p><%= _('You can only request information about the environment from this authority.')%></p>
+ <% end %>
+ <% else %>
+ <% if @public_body.not_requestable_reason == 'not_apply' %>
+ <p><%= _('Freedom of Information law does not apply to this authority, so you cannot make
+ a request to it.')%></p>
+ <% elsif @public_body.not_requestable_reason == 'defunct' %>
+ <p><%= _('This authority no longer exists, so you cannot make a request to it.')%></p>
+ <% else %>
+ <p><%= _('For an unknown reason, it is not possible to make a request to this authority.')%></p>
+ <% end %>
<% end %>
<div id="stepwise_make_request">
@@ -59,13 +69,6 @@
<%= link_to _("Make a request to this authority"), new_request_to_body_path(:url_name => @public_body.url_name), :class => "link_button_green" %>
<% elsif @public_body.has_notes? %>
<%= @public_body.notes_as_html.html_safe %>
- <% elsif @public_body.not_requestable_reason == 'not_apply' %>
- <%= _('Freedom of Information law does not apply to this authority, so you cannot make
- a request to it.')%>
- <% elsif @public_body.not_requestable_reason == 'defunct' %>
- <%= _('This authority no longer exists, so you cannot make a request to it.')%>
- <% else %>
- <%= _('For an unknown reason, it is not possible to make a request to this authority.')%>
<% end %>
<% if @public_body.override_request_email %>
@@ -78,12 +81,14 @@
<div id="foi_results_section">
<% if @public_body.info_requests.size == 0 %>
- <% if @public_body.eir_only? %>
- <h2><%= _('Environmental Information Regulations requests made using this site') %></h2>
- <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site yet.</p>
- <% else %>
- <h2><%= _('Freedom of Information requests made using this site')%></h2>
- <p><%= _('Nobody has made any Freedom of Information requests to {{public_body_name}} using this site yet.', :public_body_name => h(@public_body.name))%></p>
+ <% if @public_body.is_requestable? or @public_body.not_requestable_reason != 'defunct' %>
+ <% if @public_body.eir_only? %>
+ <h2><%= _('Environmental Information Regulations requests made using this site') %></h2>
+ <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site yet.</p>
+ <% else %>
+ <h2><%= _('Freedom of Information requests made using this site')%></h2>
+ <p><%= _('Nobody has made any Freedom of Information requests to {{public_body_name}} using this site yet.', :public_body_name => h(@public_body.name))%></p>
+ <% end %>
<% end %>
<% else %>
<h2 class="foi_results">
diff --git a/app/views/request/_sidebar.html.erb b/app/views/request/_sidebar.html.erb
index aba5c2fb3..e08f43eaa 100644
--- a/app/views/request/_sidebar.html.erb
+++ b/app/views/request/_sidebar.html.erb
@@ -58,7 +58,7 @@
<%= render :partial => 'request/request_listing_short_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
<% end %>
<% if @xapian_similar_more %>
- <p><%= link_to _("More similar requests"), similar_request_path(@info_request) %></p>
+ <p><%= link_to _("More similar requests"), similar_request_path(@info_request.url_title) %></p>
<% end %>
<!-- Important terms: <%= @xapian_similar.important_terms.join(" ") %> -->
<% end %>
diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb
index 8b7d38ac0..f8b97ffe3 100644
--- a/app/views/request/new.html.erb
+++ b/app/views/request/new.html.erb
@@ -141,7 +141,7 @@
<% if !@info_request.tag_string.empty? %>
<p class="form_note">
- <!-- <label class="form_label" for="info_request_tag_string">Tags:</label>
+ <!-- <label class="form_label" for="info_request_tag_string"><%= _("Tags (separated by a space):") %></label>
<%= f.text_field :tag_string, :size => 50 %> -->
<%= f.hidden_field(:tag_string) %>
diff --git a/app/views/request/similar.html.erb b/app/views/request/similar.html.erb
index 0d53f6919..eb7ff636d 100644
--- a/app/views/request/similar.html.erb
+++ b/app/views/request/similar.html.erb
@@ -1,5 +1,16 @@
-<% @title = "Requests similar to '" + h(@info_request.title) + "'" + @page_desc %>
-<h1><%="Requests similar to '" + request_link(@info_request) + "'" + @page_desc %></h1>
+<%- if @page > 1 %>
+ <%- @title = _("Requests similar to '{{request_title}}' (page {{page}})", {:page => @page, :request_title => @info_request.title}) %>
+<%- else %>
+<%- @title = _("Requests similar to '{{request_title}}'", {:request_title => @info_request.title}) %>
+<%- end %>
+
+<h1>
+ <%- if @page > 1 %>
+ <%= _("Requests similar to '{{request_title}}' (page {{page}})", {:page => @page, :request_title => request_link(@info_request)}) %>
+ <%- else %>
+ <%= _("Requests similar to '{{request_title}}'", {:request_title => request_link(@info_request)}) %>
+ <%- end %>
+</h1>
<!-- Important terms: <%= @xapian_object.important_terms.join(" ") %> -->