aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_general_controller.rb3
-rw-r--r--app/controllers/application_controller.rb1
-rw-r--r--app/controllers/request_game_controller.rb3
-rw-r--r--app/mailers/request_mailer.rb14
-rw-r--r--app/models/info_request.rb7
-rw-r--r--app/models/outgoing_message.rb2
-rw-r--r--app/models/user.rb1
-rw-r--r--app/views/admin_public_body/edit.html.erb2
-rw-r--r--app/views/request/_request_listing_single.html.erb18
-rw-r--r--app/views/request_game/play.html.erb24
10 files changed, 41 insertions, 34 deletions
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb
index f2414eeab..13edec37d 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.rb
@@ -23,8 +23,7 @@ class AdminGeneralController < AdminController
@requires_admin_requests = InfoRequest.find_in_state('requires_admin')
@error_message_requests = InfoRequest.find_in_state('error_message')
@attention_requests = InfoRequest.find_in_state('attention_requested')
- @blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"],
- :order => "updated_at")
+ @blank_contacts = PublicBody.where(:request_email => "").order(:updated_at).select { |pb| !pb.defunct? }
@old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,
:conditions => ["prominence = 'normal'"])
@holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 044f8e10f..e80c6a823 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -132,7 +132,6 @@ class ApplicationController < ActionController::Base
def validate_session_timestamp
if session[:user_id] && session.key?(:ttl) && session[:ttl] < SESSION_TTL.ago
clear_session_credentials
- redirect_to signin_path
end
end
diff --git a/app/controllers/request_game_controller.rb b/app/controllers/request_game_controller.rb
index 298818bc7..7eadc1204 100644
--- a/app/controllers/request_game_controller.rb
+++ b/app/controllers/request_game_controller.rb
@@ -13,7 +13,8 @@ class RequestGameController < ApplicationController
@total = InfoRequest.count
@done = @total - @missing
@percentage = (@done.to_f / @total.to_f * 10000).round / 100.0
- @requests = InfoRequest.get_random_old_unclassified(3, :conditions => ["prominence = 'normal'"])
+ @requests = InfoRequest.includes(:public_body, :user).get_random_old_unclassified(3, :conditions => ["prominence = 'normal'"])
+
if @missing == 0
flash[:notice] = _('<p>All done! Thank you very much for your help.</p><p>There are <a href="{{helpus_url}}">more things you can do</a> to help {{site_name}}.</p>',
diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb
index c9decc6db..bf04b1ab9 100644
--- a/app/mailers/request_mailer.rb
+++ b/app/mailers/request_mailer.rb
@@ -64,7 +64,7 @@ class RequestMailer < ApplicationMailer
mail(:from => user.name_and_email,
:to => contact_from_name_and_email,
- :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title).html_safe)
+ :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title.html_safe))
end
# Tell the requester that a new response has arrived
@@ -80,7 +80,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("New response to your FOI request - ") + info_request.title).html_safe,
+ :subject => _("New response to your FOI request - ") + info_request.title.html_safe,
:charset => "UTF-8",
# not much we can do if the user's email is broken
:reply_to => contact_from_name_and_email)
@@ -105,7 +105,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => user.name_and_email,
- :subject => (_("Delayed response to your FOI request - ") + info_request.title).html_safe)
+ :subject => _("Delayed response to your FOI request - ") + info_request.title.html_safe)
end
# Tell the requester that the public body is very late in replying
@@ -125,7 +125,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => user.name_and_email,
- :subject => (_("You're long overdue a response to your FOI request - ") + info_request.title).html_safe)
+ :subject => _("You're long overdue a response to your FOI request - ") + info_request.title.html_safe)
end
# Tell the requester that they need to say if the new response
@@ -183,7 +183,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("Clarify your FOI request - ") + info_request.title).html_safe)
+ :subject => _("Clarify your FOI request - ") + info_request.title.html_safe)
end
# Tell requester that somebody add an annotation to their request
@@ -197,7 +197,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("Somebody added a note to your FOI request - ") + info_request.title).html_safe)
+ :subject => _("Somebody added a note to your FOI request - ") + info_request.title.html_safe)
end
def comment_on_alert_plural(info_request, count, earliest_unalerted_comment)
@count, @info_request = count, info_request
@@ -209,7 +209,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("Some notes have been added to your FOI request - ") + info_request.title).html_safe)
+ :subject => _("Some notes have been added to your FOI request - ") + info_request.title.html_safe)
end
# Class function, called by script/mailin with all incoming responses.
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 505b9d140..f9f6cffa9 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -804,11 +804,8 @@ public
# Text from the the initial request, for use in summary display
def initial_request_text
- if outgoing_messages.empty? # mainly for use with incomplete fixtures
- return ""
- end
- excerpt = self.outgoing_messages[0].get_text_for_indexing
- return excerpt
+ return '' if outgoing_messages.empty? # mainly for use with incomplete fixtures
+ outgoing_messages.first.get_text_for_indexing
end
# Returns index of last event which is described or nil if none described.
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index fa83c7381..c2c8ef4f2 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -302,7 +302,7 @@ class OutgoingMessage < ActiveRecord::Base
end
def set_default_letter
- self.body = get_default_message if body.nil?
+ self.body = get_default_message if raw_body.nil?
end
def format_of_body
diff --git a/app/models/user.rb b/app/models/user.rb
index 920c0da46..1fb5d9139 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -38,6 +38,7 @@ class User < ActiveRecord::Base
has_one :profile_photo
has_many :censor_rules, :order => 'created_at desc'
has_many :info_request_batches, :order => 'created_at desc'
+ has_many :request_classifications
validates_presence_of :email, :message => _("Please enter your email address")
validates_presence_of :name, :message => _("Please enter your name")
diff --git a/app/views/admin_public_body/edit.html.erb b/app/views/admin_public_body/edit.html.erb
index dcafbd270..fc9c25e8f 100644
--- a/app/views/admin_public_body/edit.html.erb
+++ b/app/views/admin_public_body/edit.html.erb
@@ -13,7 +13,7 @@
<div class="row">
<div class="span8">
<div class="well">
- <%= link_to 'Show', admin_bodies_path(@public_body), :class => "btn" %>
+ <%= link_to 'Show', admin_body_path(@public_body), :class => "btn" %>
<%= link_to 'List all', admin_bodies_path, :class => "btn" %>
</div>
</div>
diff --git a/app/views/request/_request_listing_single.html.erb b/app/views/request/_request_listing_single.html.erb
index 50f889d75..0f1d7f4ef 100644
--- a/app/views/request/_request_listing_single.html.erb
+++ b/app/views/request/_request_listing_single.html.erb
@@ -2,14 +2,20 @@
<span class="head">
<%= link_to h(info_request.title), (@play_urls ? categorise_request_path(:url_title => info_request.url_title) : request_path(info_request)) %>
</span>
+
<span class="desc">
<%= excerpt(info_request.initial_request_text, "", :radius => 150) %>
- </span>
- <span class="bottomline icon_<%= info_request.calculate_status %>">
- <strong>
+ </span>
+
+ <span class="bottomline icon_<%= info_request.calculate_status %>">
+ <strong>
<%= info_request.display_status %>
- </strong><br>
- <%= _('Requested from {{public_body_name}} by {{info_request_user}} on {{date}}',:public_body_name=>public_body_link(info_request.public_body),:info_request_user=>user_link(info_request.user),:date=>simple_date(info_request.created_at)) %>
- </span>
+ </strong>
+ <br>
+ <%= _('Requested from {{public_body_name}} by {{info_request_user}} on {{date}}',
+ :public_body_name => public_body_link(info_request.public_body),
+ :info_request_user => user_link(info_request.user),
+ :date => simple_date(info_request.created_at)) %>
+ </span>
</div>
diff --git a/app/views/request_game/play.html.erb b/app/views/request_game/play.html.erb
index 783bb7f00..44fe641f9 100644
--- a/app/views/request_game/play.html.erb
+++ b/app/views/request_game/play.html.erb
@@ -10,43 +10,47 @@
%>
<br><%=pluralize(@missing, 'request')%> left to categorise / <%=@total %> total
</p>
+
<h2>Top recent players</h2>
<table>
- <% c = 0; for classifications in @league_table_28_days %>
+ <% @league_table_28_days.each_with_index do |classifications, index| %>
<tr>
- <td> <%= c += 1 %>. <td>
+ <td> <%= index += 1 %>. <td>
<td> <%= user_link(classifications.user) %> </td>
- <td> <%=pluralize(classifications.cnt, 'request').gsub(" ", "&nbsp;").html_safe %> </td>
+ <td> <%= pluralize(classifications.cnt, 'request').gsub(" ", "&nbsp;").html_safe %> </td>
</tr>
<% end %>
</table>
<h2>All time best players</h2>
<table>
- <% c = 0; for classifications in @league_table_all_time %>
+ <% @league_table_all_time.each_with_index do |classifications, index| %>
<tr>
- <td> <%= c += 1 %>. <td>
+ <td> <%= index += 1 %>. <td>
<td> <%= user_link(classifications.user) %> </td>
<td> <%= pluralize(classifications.cnt, 'request').gsub(" ", "&nbsp;").html_safe %> </td>
</tr>
<% end %>
</table>
</div>
+
<div id="game">
<h2><%= _("Play the request categorisation game!")%></h2>
+
<p><%= _("Some people who've made requests haven't let us know whether they were
successful or not. We need <strong>your</strong> help &ndash;
choose one of these requests, read it, and let everyone know whether or not the
information has been provided. Everyone'll be exceedingly grateful.")%></p>
- <% for info_request in @requests %>
+
+ <% @requests.each do |info_request| %>
<%= render :partial => 'request/request_listing_single', :locals => { :info_request => info_request } %>
<% end %>
+
<p id="game_buttons">
- <%= button_to _('I don\'t like these ones &mdash; give me some more!'), categorise_play_url %>
- <%= button_to _('I don\'t want to do any more tidying now!'), categorise_stop_url %>
+ <%= button_to _('I don\'t like these ones &mdash; give me some more!'), categorise_play_url %>
+ <%= button_to _('I don\'t want to do any more tidying now!'), categorise_stop_url %>
</p>
+
<p><%= _('Thanks for helping - your work will make it easier for everyone to find successful
responses, and maybe even let us make league tables...')%></p>
</div>
-
-