aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/application.js1
-rw-r--r--app/assets/javascripts/general.js8
-rw-r--r--app/controllers/admin_user_controller.rb6
-rw-r--r--app/controllers/application_controller.rb10
-rw-r--r--app/controllers/comment_controller.rb67
-rw-r--r--app/controllers/help_controller.rb9
-rw-r--r--app/controllers/request_controller.rb4
-rw-r--r--app/controllers/services_controller.rb11
-rw-r--r--app/controllers/track_controller.rb19
-rw-r--r--app/helpers/admin_helper.rb5
-rw-r--r--app/helpers/application_helper.rb42
-rwxr-xr-xapp/helpers/link_to_helper.rb69
-rw-r--r--app/helpers/track_helper.rb122
-rw-r--r--app/models/contact_validator.rb2
-rw-r--r--app/models/track_thing.rb137
-rw-r--r--app/views/admin_request/_some_annotations.html.erb95
-rw-r--r--app/views/admin_request/show.html.erb2
-rw-r--r--app/views/comment/_single_comment.text.erb2
-rw-r--r--app/views/general/search.html.erb2
-rw-r--r--app/views/help/contact.html.erb5
-rw-r--r--app/views/info_request_batch/show.html.erb2
-rw-r--r--app/views/public_body/show.html.erb2
-rw-r--r--app/views/request/_list_results.html.erb2
-rw-r--r--app/views/request/_outgoing_correspondence.text.erb2
-rw-r--r--app/views/request/_request_listing_via_event.html.erb29
-rw-r--r--app/views/request/_resent_outgoing_correspondence.text.erb2
-rw-r--r--app/views/request/similar.html.erb2
-rw-r--r--app/views/track/_track_set.erb6
-rw-r--r--app/views/track/atom_feed.atom.erb2
-rw-r--r--app/views/track_mailer/event_digest.text.erb2
-rw-r--r--app/views/user/river.html.erb3
-rw-r--r--app/views/user/show.html.erb6
32 files changed, 456 insertions, 222 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index d8aed6346..1b6c98535 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -1,6 +1,7 @@
// ...
//= require jquery
//= require jquery.ui.datepicker
+//= require jquery.ui.position
//= require jquery.cookie
//= require general
//= require ba-throttle-debounce
diff --git a/app/assets/javascripts/general.js b/app/assets/javascripts/general.js
index 529bbeb04..002eef760 100644
--- a/app/assets/javascripts/general.js
+++ b/app/assets/javascripts/general.js
@@ -27,8 +27,8 @@ $(document).ready(function() {
return false;
});
- // "link to this" widget
- $('a.link_to_this').click(function() {
+ // "link to this" widget
+ $('a.link_to_this').click(function() {
var box = $('div#link_box');
var location = window.location.protocol + "//" + window.location.hostname + $(this).attr('href');
box.width(location.length + " em");
@@ -36,12 +36,12 @@ $(document).ready(function() {
box.show();
box.find('input').select();
box.position({
- my: "left top",
+ my: "right center",
at: "left bottom",
of: this,
collision: "fit" });
return false;
- });
+ });
$('.close-button').click(function() { $(this).parent().hide() });
$('div#variety-filter a').each(function() {
diff --git a/app/controllers/admin_user_controller.rb b/app/controllers/admin_user_controller.rb
index 940a5fe8f..a6438e151 100644
--- a/app/controllers/admin_user_controller.rb
+++ b/app/controllers/admin_user_controller.rb
@@ -99,6 +99,12 @@ class AdminUserController < AdminController
redirect_to admin_user_show_url(@admin_user)
end
+ def modify_comment_visibility
+ @visibility_value = params.key?(:hide_selected) ? false : true
+ Comment.update_all(["visible=?", @visibility_value], :id => params[:comment_ids])
+ redirect_to :back
+ end
+
private
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 370e8e15c..410778d9a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -131,6 +131,7 @@ class ApplicationController < ActionController::Base
case exception
when ActiveRecord::RecordNotFound, RouteNotFound
@status = 404
+ sanitize_path(params)
when PermissionDenied
@status = 403
else
@@ -441,6 +442,15 @@ class ApplicationController < ActionController::Base
`git log -1 --format="%H"`.strip
end
+ # URL Encode the path parameter for use in render_exception
+ #
+ # params - the params Hash
+ #
+ # Returns a Hash
+ def sanitize_path(params)
+ params.merge!(:path => Rack::Utils.escape(params[:path])) if params.key?(:path)
+ 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/comment_controller.rb b/app/controllers/comment_controller.rb
index cda56a211..5e39c3a2c 100644
--- a/app/controllers/comment_controller.rb
+++ b/app/controllers/comment_controller.rb
@@ -6,34 +6,18 @@
class CommentController < ApplicationController
before_filter :check_read_only, :only => [ :new ]
+ before_filter :find_info_request, :only => [ :new ]
+ before_filter :create_track_thing, :only => [ :new ]
+ before_filter :reject_unless_comments_allowed, :only => [ :new ]
+ before_filter :reject_if_user_banned, :only => [ :new ]
protect_from_forgery :only => [ :new ]
def new
- if params[:type] == 'request'
- @info_request = InfoRequest.find_by_url_title!(params[:url_title])
- @track_thing = TrackThing.create_track_for_request(@info_request)
- if params[:comment]
- @comment = Comment.new(params[:comment].merge({
- :comment_type => 'request',
- :user => @user
- }))
- end
- else
- raise "Unknown type " + params[:type]
- end
-
- # Are comments disabled on this request?
- #
- # There is no “add comment” link when comments are disabled, so users should
- # not usually hit this unless they are explicitly attempting to avoid the comment
- # block, so we just raise an exception.
- raise "Comments are not allowed on this request" if !@info_request.comments_allowed?
-
- # Banned from adding comments?
- if !authenticated_user.nil? && !authenticated_user.can_make_comments?
- @details = authenticated_user.can_fail_html
- render :template => 'user/banned'
- return
+ if params[:comment]
+ @comment = Comment.new(params[:comment].merge({
+ :comment_type => 'request',
+ :user => @user
+ }))
end
if params[:comment]
@@ -92,5 +76,36 @@ class CommentController < ApplicationController
end
end
-end
+ private
+ def find_info_request
+ if params[:type] == 'request'
+ @info_request = InfoRequest.find_by_url_title!(params[:url_title])
+ else
+ raise "Unknown type #{ params[:type] }"
+ end
+ end
+
+ def create_track_thing
+ @track_thing = TrackThing.create_track_for_request(@info_request)
+ end
+
+ # Are comments disabled on this request?
+ #
+ # There is no “add comment” link when comments are disabled, so users should
+ # not usually hit this unless they are explicitly attempting to avoid the comment block
+ def reject_unless_comments_allowed
+ unless @info_request.comments_allowed?
+ redirect_to request_url(@info_request), :notice => "Comments are not allowed on this request"
+ end
+ end
+
+ # Banned from adding comments?
+ def reject_if_user_banned
+ if authenticated_user && !authenticated_user.can_make_comments?
+ @details = authenticated_user.can_fail_html
+ render :template => 'user/banned'
+ end
+ end
+
+end
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index 9959df6d8..9033198a0 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -9,6 +9,7 @@ class HelpController < ApplicationController
# we don't even have a control subroutine for most help pages, just see their templates
before_filter :long_cache
+ before_filter :catch_spam, :only => [:contact]
def unhappy
@info_request = nil
@@ -69,4 +70,12 @@ class HelpController < ApplicationController
end
+ private
+
+ def catch_spam
+ if request.post? && !params[:contact][:comment].empty?
+ redirect_to frontpage_url
+ end
+ end
+
end
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index a94461758..6445dd685 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -447,9 +447,9 @@ class RequestController < ApplicationController
flash[:notice] = case info_request.calculate_status
when 'waiting_response'
_("<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get a response promptly, and normally before the end of <strong>
-{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>simple_date(info_request.date_response_required_by))
+{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>view_context.simple_date(info_request.date_response_required_by))
when 'waiting_response_overdue'
- _("<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response promptly, and normally before the end of <strong>{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>simple_date(info_request.date_response_required_by))
+ _("<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response promptly, and normally before the end of <strong>{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>view_context.simple_date(info_request.date_response_required_by))
when 'waiting_response_very_overdue'
_("<p>Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.</p>", :very_late_number_of_days => AlaveteliConfiguration::reply_very_late_after_days, :late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
when 'not_held'
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index 78c494dba..97c47c448 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -17,8 +17,15 @@ class ServicesController < ApplicationController
text = _("Hello! You can make Freedom of Information requests within {{country_name}} at {{link_to_website}}",
:country_name => found_country[:country_name], :link_to_website => "<a href=\"#{found_country[:url]}\">#{found_country[:name]}</a>".html_safe)
else
- current_country = WorldFOIWebsites.by_code(iso_country_code)[:country_name]
- text = _("Hello! We have an <a href=\"/help/alaveteli?country_name=#{CGI.escape(current_country)}\">important message</a> for visitors outside {{country_name}}", :country_name => current_country)
+ country_data = WorldFOIWebsites.by_code(iso_country_code)
+ if country_data
+ text = _("Hello! We have an <a href=\"{{url}}\">important message</a> for visitors outside {{country_name}}",
+ :country_name => country_data[:country_name],
+ :url => "/help/alaveteli?country_name=#{CGI.escape(country_data[:country_name])}")
+ else
+ text = _("Hello! We have an <a href=\"{{url}}\">important message</a> for visitors in other countries",
+ :url => "/help/alaveteli")
+ end
end
ensure
FastGettext.locale = old_fgt_locale
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index 83e05ebbc..dccc52efc 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -118,7 +118,7 @@ class TrackController < ApplicationController
if @user
@existing_track = TrackThing.find_existing(@user, @track_thing)
if @existing_track
- flash[:notice] = _("You are already following updates about {{track_description}}", :track_description => @track_thing.params[:list_description])
+ flash[:notice] = view_context.already_subscribed_notice(@track_thing)
return true
end
end
@@ -130,11 +130,7 @@ class TrackController < ApplicationController
@track_thing.track_medium = 'email_daily'
@track_thing.tracking_user_id = @user.id
@track_thing.save!
- if @user.receive_email_alerts
- flash[:notice] = _('You will now be emailed updates about {{track_description}}. <a href="{{change_email_alerts_url}}">Prefer not to receive emails?</a>', :track_description => @track_thing.params[:list_description], :change_email_alerts_url => url_for(:controller => "user", :action => "wall", :url_name => @user.url_name))
- else
- flash[:notice] = _('You are now <a href="{{wall_url_user}}">following</a> updates about {{track_description}}', :track_description => @track_thing.params[:list_description], :wall_url_user => url_for(:controller => "user", :action => "wall", :url_name => @user.url_name))
- end
+ flash[:notice] = render_to_string(:partial => 'track_set').html_safe
return true
end
@@ -183,16 +179,8 @@ class TrackController < ApplicationController
new_medium = params[:track_medium]
if new_medium == 'delete'
track_thing.destroy
- flash[:notice] = _("You are no longer following {{track_description}}.", :track_description => track_thing.params[:list_description])
+ flash[:notice] = view_context.unsubscribe_notice(track_thing)
redirect_to URI.parse(params[:r]).path
-
- # Reuse code like this if we let medium change again.
- #elsif new_medium == 'email_daily'
- # track_thing.track_medium = new_medium
- # track_thing.created_at = Time.now() # as created_at is used to limit the alerts to start with
- # track_thing.save!
- # flash[:notice] = "You are now tracking " + track_thing.params[:list_description] + " by email daily"
- # redirect_to user_url(track_thing.tracking_user)
else
raise "new medium not handled " + new_medium
end
@@ -217,7 +205,6 @@ class TrackController < ApplicationController
for track_thing in TrackThing.find(:all, :conditions => [ "track_type = ? and tracking_user_id = ?", track_type, user_id ])
track_thing.destroy
end
- flash[:notice] += "</ul>"
redirect_to params[:r]
end
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
index 059cebdfa..151e53758 100644
--- a/app/helpers/admin_helper.rb
+++ b/app/helpers/admin_helper.rb
@@ -33,5 +33,10 @@ module AdminHelper
link_to(eye, user_path(user), :title => "view user's page on public website") + " " +
link_to(h(user.name), admin_user_show_path(user), :title => "view full details")
end
+
+ def comment_visibility(comment)
+ comment.visible? ? 'Visible' : 'Hidden'
+ end
+
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 154697377..33525cb3d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -136,5 +136,47 @@ module ApplicationHelper
nil
end
end
+
+ def event_description(event)
+ body_link = public_body_link_absolute(event.info_request.public_body)
+ user_link = request_user_link_absolute(event.info_request)
+ date = simple_date(event.created_at)
+ case event.event_type
+ when 'sent'
+ _('Request sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',
+ :public_body_name => body_link,
+ :info_request_user => user_link,
+ :date => date)
+ when 'followup_sent'
+ case event.calculated_state
+ when 'internal_review'
+ _('Internal review request sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',
+ :public_body_name => body_link,
+ :info_request_user => user_link,
+ :date => date)
+ when 'waiting_response'
+ _('Clarification sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',
+ :public_body_name => body_link,
+ :info_request_user => user_link,
+ :date => date)
+ else
+ _('Follow up sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',
+ :public_body_name => body_link,
+ :info_request_user => user_link,
+ :date => date)
+ end
+ when 'response'
+ _('Response by {{public_body_name}} to {{info_request_user}} on {{date}}.',
+ :public_body_name => body_link,
+ :info_request_user => user_link,
+ :date => date)
+ when 'comment'
+ _('Request to {{public_body_name}} by {{info_request_user}}. Annotated by {{event_comment_user}} on {{date}}.',
+ :public_body_name => body_link,
+ :info_request_user => user_link,
+ :event_comment_user => user_link_absolute(event.comment.user),
+ :date => date)
+ end
+ end
end
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 405886a85..dd6ffa805 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -18,8 +18,8 @@ module LinkToHelper
request_url(info_request, {:only_path => true}.merge(options))
end
- def request_link(info_request, cls=nil )
- link_to h(info_request.title), request_path(info_request), :class => cls
+ def request_link(info_request, cls=nil)
+ link_to info_request.title, request_path(info_request), :class => cls
end
def request_details_path(info_request)
@@ -75,15 +75,15 @@ module LinkToHelper
end
def public_body_link_short(public_body)
- link_to h(public_body.short_or_long_name), public_body_path(public_body)
+ link_to public_body.short_or_long_name, public_body_path(public_body)
end
def public_body_link(public_body, cls=nil)
- link_to h(public_body.name), public_body_path(public_body), :class => cls
+ link_to public_body.name, public_body_path(public_body), :class => cls
end
def public_body_link_absolute(public_body) # e.g. for in RSS
- link_to h(public_body.name), public_body_url(public_body)
+ link_to public_body.name, public_body_url(public_body)
end
# Users
@@ -96,19 +96,19 @@ module LinkToHelper
end
def user_link(user, cls=nil)
- link_to h(user.name), user_path(user), :class => cls
+ link_to user.name, user_path(user), :class => cls
end
def user_link_for_request(request, cls=nil)
if request.is_external?
user_name = request.external_user_name || _("Anonymous user")
if !request.external_url.nil?
- link_to h(user_name), request.external_url
+ link_to user_name, request.external_url
else
user_name
end
else
- link_to h(request.user.name), user_path(request.user), :class => cls
+ link_to request.user.name, user_path(request.user), :class => cls
end
end
@@ -116,7 +116,7 @@ module LinkToHelper
if request.is_external?
external_text || (request.external_user_name || _("Anonymous user")) + " (external)"
else
- link_to(h(internal_text || request.user.name), admin_user_show_url(request.user))
+ link_to(internal_text || request.user.name, admin_user_show_url(request.user))
end
end
@@ -279,13 +279,58 @@ module LinkToHelper
end
end
- # Basic date format
- def simple_date(date)
+ # Public: Usually-correct format for a DateTime-ish object
+ # To define a new new format define the `simple_date_{FORMAT}` method
+ #
+ # date - a DateTime, Date or Time
+ # opts - a Hash of options (default: { format: :html})
+ # :format - :html returns a HTML <time> tag
+ # :text returns a plain String
+ #
+ # Examples
+ #
+ # simple_date(Time.now)
+ # # => "<time>..."
+ #
+ # simple_date(Time.now, :format => :text)
+ # # => "March 10, 2014"
+ #
+ # Returns a String
+ # Raises ArgumentError if the format is unrecognized
+ def simple_date(date, opts = {})
+ opts = { :format => :html }.merge(opts)
+ date_formatter = "simple_date_#{ opts[:format] }"
+
+ if respond_to?(date_formatter)
+ send(date_formatter, date)
+ else
+ raise ArgumentError, "Unrecognised format :#{ opts[:format] }"
+ end
+ end
+
+ # Usually-correct HTML formatting of a DateTime-ish object
+ # Use LinkToHelper#simple_date with desired formatting options
+ #
+ # date - a DateTime, Date or Time
+ #
+ # Returns a String
+ def simple_date_html(date)
+ date = date.in_time_zone unless date.is_a? Date
+ time_tag date, simple_date_text(date), :title => date.to_s
+ end
+
+ # Usually-correct plain text formatting of a DateTime-ish object
+ # Use LinkToHelper#simple_date with desired formatting options
+ #
+ # date - a DateTime, Date or Time
+ #
+ # Returns a String
+ def simple_date_text(date)
date = date.in_time_zone.to_date unless date.is_a? Date
date_format = _("simple_date_format")
date_format = :long if date_format == "simple_date_format"
- return I18n.l(date, :format => date_format)
+ I18n.l(date, :format => date_format)
end
def simple_time(date)
diff --git a/app/helpers/track_helper.rb b/app/helpers/track_helper.rb
new file mode 100644
index 000000000..7bd0fa55d
--- /dev/null
+++ b/app/helpers/track_helper.rb
@@ -0,0 +1,122 @@
+module TrackHelper
+
+ def already_subscribed_notice(track_thing)
+ case track_thing.track_type
+ when 'request_updates'
+ _("You are already subscribed to '{{link_to_request}}', a request",
+ :link_to_request => request_link(track_thing.info_request))
+ when 'all_new_requests'
+ _('You are already subscribed to any <a href="{{new_requests_url}}">new requests</a>',
+ :new_requests_url => request_list_path)
+ when 'all_successful_requests'
+ _('You are already subscribed to any <a href="{{successful_requests_url}}">successful requests</a>',
+ :successful_requests_url => request_list_successful_path )
+ when 'public_body_updates'
+ _("You are already subscribed to '{{link_to_authority}}', a public authority",
+ :link_to_authority => public_body_link(track_thing.public_body))
+ when 'user_updates'
+ _("You are already subscribed to '{{link_to_user}}', a person",
+ :link_to_user => user_link(track_thing.tracked_user))
+ when 'search_query'
+ _('You are already subscribed to <a href="{{search_url}}">this search</a>',
+ :search_url => search_path([track_thing.track_query, 'newest', 'advanced']))
+ end
+ end
+
+ def subscribe_email_notice(track_thing)
+ case track_thing.track_type
+ when 'request_updates'
+ _("You will now be emailed updates about '{{link_to_request}}', a request",
+ :link_to_request => request_link(track_thing.info_request))
+ when 'all_new_requests'
+ _('You will now be emailed updates about any <a href="{{new_requests_url}}">new requests</a>',
+ :new_requests_url => request_list_path)
+ when 'all_successful_requests'
+ _('You will now be emailed updates about <a href="{{successful_requests_url}}">successful requests</a>',
+ :successful_requests_url => request_list_successful_path )
+ when 'public_body_updates'
+ _("You will now be emailed updates about '{{link_to_authority}}', a public authority",
+ :link_to_authority => public_body_link(track_thing.public_body))
+ when 'user_updates'
+ _("You will now be emailed updates about '{{link_to_user}}', a person",
+ :link_to_user => user_link(track_thing.tracked_user))
+ when 'search_query'
+ _("You will now be emailed updates about <a href=\"{{search_url}}\">this search</a>",
+ :search_url => search_path([track_thing.track_query, 'newest', 'advanced']))
+ end
+ end
+
+ def subscribe_follow_notice(track_thing)
+ wall_url_user = show_user_wall_path(:url_name => track_thing.tracking_user.url_name)
+ case track_thing.track_type
+ when 'request_updates'
+ _('You are now <a href="{{wall_url_user}}">following</a> updates about \'{{link_to_request}}\', a request',
+ :link_to_request => request_link(track_thing.info_request),
+ :wall_url_user => wall_url_user)
+ when 'all_new_requests'
+ _('You are now <a href="{{wall_url_user}}">following</a> updates about <a href="{{new_requests_url}}">new requests</a>',
+ :new_requests_url => request_list_path,
+ :wall_url_user => wall_url_user)
+ when 'all_successful_requests'
+ _('You are now <a href="{{wall_url_user}}">following</a> updates about <a href="{{successful_requests_url}}">successful requests</a>',
+ :successful_requests_url => request_list_successful_path,
+ :wall_url_user => wall_url_user)
+ when 'public_body_updates'
+ _('You are now <a href="{{wall_url_user}}">following</a> updates about \'{{link_to_authority}}\', a public authority',
+ :wall_url_user => wall_url_user,
+ :link_to_authority => public_body_link(track_thing.public_body))
+ when 'user_updates'
+ _('You are now <a href="{{wall_url_user}}">following</a> updates about \'{{link_to_user}}\', a person',
+ :wall_url_user => wall_url_user,
+ :link_to_user => user_link(track_thing.tracked_user))
+ when 'search_query'
+ _('You are now <a href="{{wall_url_user}}">following</a> updates about <a href="{{search_url}}">this search</a>',
+ :wall_url_user => wall_url_user,
+ :search_url => search_path([track_thing.track_query, 'newest', 'advanced']))
+ end
+ end
+
+ def unsubscribe_notice(track_thing)
+ case track_thing.track_type
+ when 'request_updates'
+ _("You are no longer following '{{link_to_request}}', a request",
+ :link_to_request => request_link(track_thing.info_request))
+ when 'all_new_requests'
+ _('You are no longer following <a href="{{new_requests_url}}">new requests</a>',
+ :new_requests_url => request_list_path)
+ when 'all_successful_requests'
+ _('You are no longer following <a href="{{successful_requests_url}}">successful requests</a>',
+ :successful_requests_url => request_list_successful_path )
+ when 'public_body_updates'
+ _("You are no longer following '{{link_to_authority}}', a public authority",
+ :link_to_authority => public_body_link(track_thing.public_body))
+ when 'user_updates'
+ _("You are no longer following '{{link_to_user}}', a person",
+ :link_to_user => user_link(track_thing.tracked_user))
+ when 'search_query'
+ _('You are no longer following <a href="{{search_url}}">this search</a>',
+ :search_url => search_path([track_thing.track_query, 'newest', 'advanced']))
+ end
+ end
+
+ def track_description(track_thing)
+ case track_thing.track_type
+ when 'request_updates'
+ _("'{{link_to_request}}', a request",
+ :link_to_request => request_link(track_thing.info_request))
+ when 'all_new_requests'
+ link_to(_('new requests'), request_list_path)
+ when 'all_successful_requests'
+ link_to(_('successful requests'), request_list_successful_path)
+ when 'public_body_updates'
+ _("'{{link_to_authority}}', a public authority",
+ :link_to_authority => public_body_link(track_thing.public_body))
+ when 'user_updates'
+ _("'{{link_to_user}}', a person",
+ :link_to_user => user_link(track_thing.tracked_user))
+ when 'search_query'
+ link_to(track_thing.track_query_description,
+ search_path([track_thing.track_query, 'newest', 'advanced']))
+ end
+ end
+end
diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb
index 65e539669..e9a6e491c 100644
--- a/app/models/contact_validator.rb
+++ b/app/models/contact_validator.rb
@@ -7,7 +7,7 @@
class ContactValidator
include ActiveModel::Validations
- attr_accessor :name, :email, :subject, :message
+ attr_accessor :name, :email, :subject, :message, :comment
validates_presence_of :name, :message => N_("Please enter your name")
validates_presence_of :email, :message => N_("Please enter your email address")
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index d5dda7bb5..13b6f78dd 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -69,66 +69,30 @@ class TrackThing < ActiveRecord::Base
end
def track_query_description
- # XXX this is very brittle... we should probably ask users
- # simply to name their tracks when they make them?
- original_text = parsed_text = self.track_query.gsub(/([()]|OR)/, "")
- filters = parsed_text.scan /\b\S+:\S+\b/
- varieties = Set.new
- date = ""
- statuses = Set.new
- for filter in filters
- parsed_text = parsed_text.sub(filter, "")
- if filter =~ /variety:user/
- varieties << _("users")
- end
- if filter =~ /variety:comment/
- varieties << _("comments")
- end
- if filter =~ /variety:authority/
- varieties << _("authorities")
- end
- if filter =~ /(variety:(sent|followup_sent|response)|latest_status)/
- varieties << _("requests")
- end
- if filter =~ /[0-9\/]+\.\.[0-9\/]+/
- date = _("between two dates")
- end
- if filter =~ /(rejected|not_held)/
- statuses << _("unsuccessful")
- end
- if filter =~ /(:successful|:partially_successful)/
- statuses << _("successful")
- end
- if filter =~ /waiting/
- statuses << _("awaiting a response")
- end
- end
- if filters.empty?
- parsed_text = original_text
- end
- descriptions = []
- if varieties.include? _("requests")
- if statuses.empty?
- # HACK: Relies on the 'descriptions.sort' below to luckily put this first
- descriptions << _("all requests")
+ filter_description = query_filter_description('(variety:sent OR variety:followup_sent OR variety:response OR variety:comment)',
+ :no_query => N_("all requests or comments"),
+ :query => N_("all requests or comments matching text '{{query}}'"))
+ return filter_description if filter_description
+ filter_description = query_filter_description('(latest_status:successful OR latest_status:partially_successful)',
+ :no_query => N_("requests which are successful"),
+ :query => N_("requests which are successful matching text '{{query}}'"))
+ return filter_description if filter_description
+ return _("anything matching text '{{query}}'", :query => track_query)
+ end
+
+ # Return a readable query description for queries involving commonly used filter clauses
+ def query_filter_description(string, options)
+ parsed_query = track_query.gsub(string, '')
+ if parsed_query != track_query
+ parsed_query.strip!
+ if parsed_query.empty?
+ _(options[:no_query])
else
- descriptions << _("requests which are {{list_of_statuses}}", :list_of_statuses => Array(statuses).sort.join(_(' or ')))
+ _(options[:query], :query => parsed_query)
end
- varieties -= [_("requests")]
end
- if descriptions.empty? and varieties.empty?
- varieties << _("anything")
- end
- descriptions += Array(varieties)
- parsed_text = parsed_text.strip
- 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
- return descriptions
end
-
def TrackThing.create_track_for_request(info_request)
track_thing = TrackThing.new
track_thing.track_type = 'request_updates'
@@ -194,30 +158,32 @@ class TrackThing < ActiveRecord::Base
end
# Return hash of text parameters describing the request etc.
- include LinkToHelper
def params
if @params.nil?
if self.track_type == 'request_updates'
@params = {
# Website
- :list_description => _("'{{link_to_request}}', a request",
- :link_to_request => ("<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>").html_safe), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+
:verb_on_page => _("Follow this request"),
:verb_on_page_already => _("You are already following this request"),
# Email
- :title_in_email => _("New updates for the request '{{request_title}}'", :request_title => self.info_request.title.html_safe),
- :title_in_rss => _("New updates for the request '{{request_title}}'", :request_title => self.info_request.title),
+ :title_in_email => _("New updates for the request '{{request_title}}'",
+ :request_title => self.info_request.title.html_safe),
+ :title_in_rss => _("New updates for the request '{{request_title}}'",
+ :request_title => self.info_request.title),
# Authentication
- :web => _("To follow the request '{{request_title}}'", :request_title => CGI.escapeHTML(self.info_request.title)),
- :email => _("Then you will be updated whenever the request '{{request_title}}' is updated.", :request_title => CGI.escapeHTML(self.info_request.title)),
- :email_subject => _("Confirm you want to follow the request '{{request_title}}'", :request_title => self.info_request.title),
+ :web => _("To follow the request '{{request_title}}'",
+ :request_title => self.info_request.title),
+ :email => _("Then you will be updated whenever the request '{{request_title}}' is updated.",
+ :request_title => self.info_request.title),
+ :email_subject => _("Confirm you want to follow the request '{{request_title}}'",
+ :request_title => self.info_request.title),
# RSS sorting
:feed_sortby => 'newest'
}
elsif self.track_type == 'all_new_requests'
@params = {
# Website
- :list_description => _("any <a href=\"/list\">new requests</a>"),
:verb_on_page => _("Follow all new requests"),
:verb_on_page_already => _("You are already following new requests"),
# Email
@@ -233,7 +199,6 @@ class TrackThing < ActiveRecord::Base
elsif self.track_type == 'all_successful_requests'
@params = {
# Website
- :list_description => _("any <a href=\"/list/successful\">successful requests</a>"),
:verb_on_page => _("Follow new successful responses"),
:verb_on_page_already => _("You are following all new successful responses"),
# Email
@@ -252,39 +217,51 @@ class TrackThing < ActiveRecord::Base
elsif self.track_type == 'public_body_updates'
@params = {
# Website
- :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => ("<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>").html_safe), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
- :verb_on_page => _("Follow requests to {{public_body_name}}",:public_body_name=>CGI.escapeHTML(self.public_body.name)),
- :verb_on_page_already => _("You are already following requests to {{public_body_name}}", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
+ :verb_on_page => _("Follow requests to {{public_body_name}}",
+ :public_body_name => self.public_body.name),
+ :verb_on_page_already => _("You are already following requests to {{public_body_name}}",
+ :public_body_name => self.public_body.name),
# Email
- :title_in_email => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'",
- :title_in_rss => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'",
+ :title_in_email => _("{{foi_law}} requests to '{{public_body_name}}'",
+ :foi_law => self.public_body.law_only_short,
+ :public_body_name => self.public_body.name),
+ :title_in_rss => _("{{foi_law}} requests to '{{public_body_name}}'",
+ :foi_law => self.public_body.law_only_short,
+ :public_body_name => self.public_body.name),
# Authentication
- :web => _("To follow requests made using {{site_name}} to the public authority '{{public_body_name}}'", :site_name=>AlaveteliConfiguration::site_name, :public_body_name=>CGI.escapeHTML(self.public_body.name)),
- :email => _("Then you will be notified whenever someone requests something or gets a response from '{{public_body_name}}'.", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
- :email_subject => _("Confirm you want to follow requests to '{{public_body_name}}'", :public_body_name=>self.public_body.name),
+ :web => _("To follow requests made using {{site_name}} to the public authority '{{public_body_name}}'",
+ :site_name => AlaveteliConfiguration::site_name,
+ :public_body_name => self.public_body.name),
+ :email => _("Then you will be notified whenever someone requests something or gets a response from '{{public_body_name}}'.",
+ :public_body_name => self.public_body.name),
+ :email_subject => _("Confirm you want to follow requests to '{{public_body_name}}'",
+ :public_body_name => self.public_body.name),
# RSS sorting
:feed_sortby => 'newest'
}
elsif self.track_type == 'user_updates'
@params = {
# Website
- :list_description => _("'{{link_to_user}}', a person", :link_to_user => ("<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>").html_safe), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Follow this person"),
:verb_on_page_already => _("You are already following this person"),
# Email
- :title_in_email => _("FOI requests by '{{user_name}}'", :user_name=>self.tracked_user.name.html_safe),
- :title_in_rss => _("FOI requests by '{{user_name}}'", :user_name=>self.tracked_user.name),
+ :title_in_email => _("FOI requests by '{{user_name}}'",
+ :user_name => self.tracked_user.name.html_safe),
+ :title_in_rss => _("FOI requests by '{{user_name}}'",
+ :user_name => self.tracked_user.name),
# Authentication
- :web => _("To follow requests by '{{user_name}}'", :user_name=>CGI.escapeHTML(self.tracked_user.name)),
- :email => _("Then you will be notified whenever '{{user_name}}' requests something or gets a response.", :user_name=>CGI.escapeHTML(self.tracked_user.name)),
- :email_subject => _("Confirm you want to follow requests by '{{user_name}}'", :user_name=>self.tracked_user.name),
+ :web => _("To follow requests by '{{user_name}}'",
+ :user_name=> self.tracked_user.name),
+ :email => _("Then you will be notified whenever '{{user_name}}' requests something or gets a response.",
+ :user_name => self.tracked_user.name),
+ :email_subject => _("Confirm you want to follow requests by '{{user_name}}'",
+ :user_name => self.tracked_user.name),
# RSS sorting
:feed_sortby => 'newest'
}
elsif self.track_type == 'search_query'
@params = {
# Website
- :list_description => ("<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + CGI.escapeHTML(self.track_query_description) + "</a>").html_safe, # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Follow things matching this search"),
:verb_on_page_already => _("You are already following things matching this search"),
# Email
diff --git a/app/views/admin_request/_some_annotations.html.erb b/app/views/admin_request/_some_annotations.html.erb
index dfd46f828..7adcdc5bb 100644
--- a/app/views/admin_request/_some_annotations.html.erb
+++ b/app/views/admin_request/_some_annotations.html.erb
@@ -1,48 +1,61 @@
-<% if comments.size > 0 %>
- <div class="accordion" id="comments">
- <% for comment in comments %>
- <div class="accordion-group">
- <div class="accordion-heading">
- <a href="#comment_<%=comment.id%>" data-toggle="collapse" data-parent="#comments"><%= chevron_right %></a>
- <%= link_to admin_request_edit_comment_path(comment) do %>
- #<%=comment.id%>
- --
- <%=h(comment.user.name)%>
- <%=admin_value(comment.created_at)%>
+<% if comments.any? %>
+ <%= form_tag admin_user_modify_comment_visibility_path do %>
+ <div class="accordion" id="comments">
+ <% comments.each do |comment| %>
+ <div class="accordion-group">
+ <div class="accordion-heading">
+ <%= check_box_tag 'comment_ids[]', comment.id %>
+
+ <a href="#comment_<%= comment.id %>" data-toggle="collapse" data-parent="#comments"><%= chevron_right %></a>
+
+ <%= link_to admin_request_edit_comment_path(comment) do %>
+ #<%= comment.id %>
+ --
+ <%= h(comment.user.name) %>
+ <%= admin_value(comment.created_at) %>
<% end %>
- <blockquote class="incoming-message">
- <%= truncate(comment.body, :length => 400) %>
- </blockquote>
- </div>
- <div id="comment_<%=comment.id%>" class="accordion-body collapse">
- <table class="table table-striped table-condensed">
- <tbody>
- <tr>
- <td colspan="2">
- By <%= user_both_links(comment.user) %>
- </td>
- </tr>
- <% comment.for_admin_column do |name, value, type, column_name |%>
+
+ <%= comment_visibility(comment) %>
+
+ <blockquote class="incoming-message">
+ <%= truncate(comment.body, :length => 400) %>
+ </blockquote>
+ </div>
+
+ <div id="comment_<%= comment.id %>" class="accordion-body collapse">
+ <table class="table table-striped table-condensed">
+ <tbody>
<tr>
- <td>
- <b><%=name%></b>
- </td>
- <td>
- <% if column_name == 'body' && !comment.visible %>
- <s><%=h comment.send(column_name) %></s>
- <% else %>
- <%=h comment.send(column_name) %>
- <% end %>
+ <td colspan="2">
+ By <%= user_both_links(comment.user) %>
</td>
</tr>
- <% end %>
- </tbody>
- </table>
+ <% comment.for_admin_column do |name, value, type, column_name |%>
+ <tr>
+ <td>
+ <b><%= name %></b>
+ </td>
+ <td>
+ <% if column_name == 'body' && !comment.visible %>
+ <s><%= h comment.send(column_name) %></s>
+ <% else %>
+ <%= h comment.send(column_name) %>
+ <% end %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </div>
+
</div>
- </div>
- <% end %>
- </div>
+ <% end %>
+ </div>
+
+ <%= submit_tag 'Hide selected', :name => 'hide_selected' %>
+ <%= submit_tag 'Unhide selected', :name => 'unhide_selected' %>
+
+ <% end %>
<% else %>
<p>None yet.</p>
-<% end %>
-
+<% end %>
diff --git a/app/views/admin_request/show.html.erb b/app/views/admin_request/show.html.erb
index 2589e52b4..9c04badeb 100644
--- a/app/views/admin_request/show.html.erb
+++ b/app/views/admin_request/show.html.erb
@@ -118,7 +118,7 @@
</label>
<div class="controls">
<%= link_to 'Generate URL', admin_request_generate_upload_url_path(@info_request), :class => "btn" %>
- <p class="help-block">(see also option to general URLs for individual incoming messages below)</p>
+ <p class="help-block">(see also option to generate URLs for individual incoming messages below)</p>
</div>
</div>
<%= form_tag admin_request_hide_path(@info_request), :class => "form form-inline", :id => "hide_request_form", 'data-info-request-id' => @info_request.id.to_s do %>
diff --git a/app/views/comment/_single_comment.text.erb b/app/views/comment/_single_comment.text.erb
index 925e8b688..4932a7e4a 100644
--- a/app/views/comment/_single_comment.text.erb
+++ b/app/views/comment/_single_comment.text.erb
@@ -1,2 +1,2 @@
-<%= _("{{username}} left an annotation:", :username =>comment.user.name) %> (<%= simple_date(comment.created_at || Time.now) %>)
+<%= _("{{username}} left an annotation:", :username =>comment.user.name) %> (<%= simple_date((comment.created_at || Time.now), :format => :text) %>)
<%= comment.body.strip %>
diff --git a/app/views/general/search.html.erb b/app/views/general/search.html.erb
index 18f258444..45268d7f0 100644
--- a/app/views/general/search.html.erb
+++ b/app/views/general/search.html.erb
@@ -191,7 +191,7 @@
<div class="results_block">
<% for result in @xapian_requests.results %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %>
<% end %>
</div>
diff --git a/app/views/help/contact.html.erb b/app/views/help/contact.html.erb
index ad89db9ec..e8a5fec8c 100644
--- a/app/views/help/contact.html.erb
+++ b/app/views/help/contact.html.erb
@@ -65,6 +65,11 @@
<%= f.text_area :message, :rows => 10, :cols => 60 %>
</p>
+ <p style="display:none;">
+ <%= f.label :comment, 'Do not fill in this field' %>
+ <%= f.text_field :comment %>
+ </p>
+
<% if !@last_request.nil? %>
<p>
<label class="form_label" for="contact_message">Include link to request:</label>
diff --git a/app/views/info_request_batch/show.html.erb b/app/views/info_request_batch/show.html.erb
index aaecdd45d..2c7e42072 100644
--- a/app/views/info_request_batch/show.html.erb
+++ b/app/views/info_request_batch/show.html.erb
@@ -5,7 +5,7 @@
<div class="results_section">
<div class="results_block">
<% @info_requests.each do |info_request| %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => info_request.last_event_forming_initial_request, :info_request => info_request } %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => info_request.last_event_forming_initial_request } %>
<% end %>
</div>
<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @info_request_batch.info_requests.visible.count) %>
diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb
index c36396149..a9c50e657 100644
--- a/app/views/public_body/show.html.erb
+++ b/app/views/public_body/show.html.erb
@@ -119,7 +119,7 @@
<% if !@xapian_requests.nil? %>
<% for result in @xapian_requests.results %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %>
<% end %>
<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated) %>
diff --git a/app/views/request/_list_results.html.erb b/app/views/request/_list_results.html.erb
index 4da042816..9e6b07c79 100644
--- a/app/views/request/_list_results.html.erb
+++ b/app/views/request/_list_results.html.erb
@@ -5,7 +5,7 @@
<h2 class="foi_results"><%= _('{{count}} FOI requests found', :count => @results[:matches_estimated]) %></h2>
<div class="results_block">
<% @results[:results].each do |result| %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result, :info_request => result.info_request } %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result } %>
<% end %>
</div>
<% end %>
diff --git a/app/views/request/_outgoing_correspondence.text.erb b/app/views/request/_outgoing_correspondence.text.erb
index 5375ef81b..221e359e2 100644
--- a/app/views/request/_outgoing_correspondence.text.erb
+++ b/app/views/request/_outgoing_correspondence.text.erb
@@ -3,6 +3,6 @@
<%- else %>
<%= _('From:') %> <% if @info_request.user_name %><%= @info_request.user_name %><% else %><%= "[#{_('An anonymous user')}]"%><% end %>
<%= _('To:') %> <%= @info_request.public_body.name %>
- <%= _('Date:') %> <%= simple_date(info_request_event.created_at) %>
+ <%= _('Date:') %> <%= simple_date(info_request_event.created_at, :format => :text) %>
<%= outgoing_message.get_body_for_text_display %>
<%- end %>
diff --git a/app/views/request/_request_listing_via_event.html.erb b/app/views/request/_request_listing_via_event.html.erb
index cc8bae8a9..20bc5b2c8 100644
--- a/app/views/request/_request_listing_via_event.html.erb
+++ b/app/views/request/_request_listing_via_event.html.erb
@@ -6,36 +6,21 @@ end %>
<div class="request_left">
<span class="head">
<% if event.is_incoming_message? %>
- <%= link_to highlight_words(info_request.title, @highlight_words), incoming_message_path(event.incoming_message_selective_columns("incoming_messages.id")) %>
+ <%= link_to highlight_words(event.info_request.title, @highlight_words), incoming_message_path(event.incoming_message_selective_columns("incoming_messages.id")) %>
<% elsif event.is_outgoing_message? and event.event_type == 'followup_sent' %>
- <%= link_to highlight_words(info_request.title, @highlight_words), outgoing_message_path(event.outgoing_message) %>
+ <%= link_to highlight_words(event.info_request.title, @highlight_words), outgoing_message_path(event.outgoing_message) %>
<% elsif event.is_comment? %>
- <%= link_to highlight_words(info_request.title, @highlight_words), comment_path(event.comment) %>
+ <%= link_to highlight_words(event.info_request.title, @highlight_words), comment_path(event.comment) %>
<% else %>
- <%= link_to highlight_words(info_request.title, @highlight_words), request_path(info_request) %>
+ <%= link_to highlight_words(event.info_request.title, @highlight_words), request_path(event.info_request) %>
<% end %>
</span>
<div class="requester">
- <% if event.event_type == 'sent' %>
- <%= _('Request sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at )) %>
- <% elsif event.event_type == 'followup_sent' %>
- <%=event.display_status %>
- <%= _('sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at )) %>
- <% elsif event.event_type == 'response' %>
- <%=event.display_status %>
- <%= _('by {{public_body_name}} to {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at )) %>
- <% elsif event.event_type == 'comment' %>
- <%= _('Request to {{public_body_name}} by {{info_request_user}}. Annotated by {{event_comment_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:event_comment_user=>user_link_absolute(event.comment.user),:date=>simple_date(event.created_at)) %>
- <% else %>
- <%# Events of other types will not be indexed: see InfoRequestEvent#indexed_by_search?
- However, it can happen that we see other types of event transiently here in the period
- between a change being made and the update-xapian-index job being run. %>
- <!-- Event of type '<%= event.event_type %>', id=<%= event.id %> -->
- <% end %>
+ <%= event_description(event) %>
</div>
- <span class="bottomline icon_<%= info_request.calculate_status %>">
+ <span class="bottomline icon_<%= event.info_request.calculate_status %>">
<strong>
- <%= info_request.display_status(cached_value_ok=true) %>
+ <%= event.info_request.display_status(cached_value_ok=true) %>
</strong><br>
</span>
</div>
diff --git a/app/views/request/_resent_outgoing_correspondence.text.erb b/app/views/request/_resent_outgoing_correspondence.text.erb
index d645e9488..d39f8395b 100644
--- a/app/views/request/_resent_outgoing_correspondence.text.erb
+++ b/app/views/request/_resent_outgoing_correspondence.text.erb
@@ -1,2 +1,2 @@
-<%= _('Date:') %> <%= simple_date(info_request_event.created_at) %>
+<%= _('Date:') %> <%= simple_date(info_request_event.created_at, :format => :text) %>
Sent <% if outgoing_message.message_type == 'initial_request' %> request <% elsif outgoing_message.message_type == 'followup' %> a follow up <% else %> <% raise "unknown message_type" %><% end %> to <%= public_body_link(@info_request.public_body) %> again<% if not info_request_event.same_email_as_previous_send? %>, using a new contact address<% end %>.
diff --git a/app/views/request/similar.html.erb b/app/views/request/similar.html.erb
index 5bdefc494..4ce4bf9ba 100644
--- a/app/views/request/similar.html.erb
+++ b/app/views/request/similar.html.erb
@@ -22,7 +22,7 @@
-->
<% for result in @xapian_object.results %>
<% if result[:model].class.to_s == 'InfoRequestEvent' %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %>
<% else %>
<p><strong><%= _('Unexpected search result type ')%><%=result[:model].class.to_s%></strong></p>
<% end %>
diff --git a/app/views/track/_track_set.erb b/app/views/track/_track_set.erb
new file mode 100644
index 000000000..c7665312d
--- /dev/null
+++ b/app/views/track/_track_set.erb
@@ -0,0 +1,6 @@
+<% if @user.receive_email_alerts %>
+ <%= subscribe_email_notice(@track_thing) %>
+ <%= link_to(_('Prefer not to receive emails?'), show_user_wall_path(:url_name => @user.url_name)) %>
+<% else %>
+ <%= subscribe_follow_notice(@track_thing) %>
+<% end %>
diff --git a/app/views/track/atom_feed.atom.erb b/app/views/track/atom_feed.atom.erb
index be9c39e72..892727aef 100644
--- a/app/views/track/atom_feed.atom.erb
+++ b/app/views/track/atom_feed.atom.erb
@@ -9,7 +9,7 @@
# Get the HTML content from the same partial template as website search does
content = ''
if result[:model].class.to_s == 'InfoRequestEvent'
- content += render :partial => 'request/request_listing_via_event', :formats => ['html'], :locals => { :event => result[:model], :info_request => result[:model].info_request }
+ content += render :partial => 'request/request_listing_via_event', :formats => ['html'], :locals => { :event => result[:model] }
else
content = "<p><strong>Unknown search result type " + result[:model].class.to_s + "</strong></p>"
end
diff --git a/app/views/track_mailer/event_digest.text.erb b/app/views/track_mailer/event_digest.text.erb
index 8dbc7fe06..b83c184f0 100644
--- a/app/views/track_mailer/event_digest.text.erb
+++ b/app/views/track_mailer/event_digest.text.erb
@@ -32,7 +32,7 @@
else
raise "unknown type in event_digest " + event.event_type
end
- main_text += " (" + simple_date(event.created_at) + ")\n"
+ main_text += " (" + simple_date(event.created_at, :format => :text) + ")\n"
# Main text, wrapped, words highlighted with * and indented.
if event.is_outgoing_message?
diff --git a/app/views/user/river.html.erb b/app/views/user/river.html.erb
index 9618e0aa8..7277e5ee5 100644
--- a/app/views/user/river.html.erb
+++ b/app/views/user/river.html.erb
@@ -4,8 +4,7 @@
<h1><%=@title%></h1>
<% for result in @results %>
- <%= render :partial => 'request/request_listing_via_event', :locals => {
- :event => result[:model], :info_request => result[:model].info_request } %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %>
<% end %>
</div>
diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb
index 76ecdeda0..8dd8c6b88 100644
--- a/app/views/user/show.html.erb
+++ b/app/views/user/show.html.erb
@@ -147,7 +147,7 @@
<% for result in @xapian_requests.results %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %>
<% end %>
<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.info_requests.size) %>
@@ -175,7 +175,7 @@
</h2>
<% for result in @xapian_comments.results %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %>
<% end %>
<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %>
@@ -224,7 +224,7 @@
<li>
<%= form_tag({:controller => 'track', :action => 'update', :track_id => track_thing.id}, :class => "feed_form") do %>
<div>
- <%= track_thing.params[:list_description] %>
+ <%= track_description(track_thing) %>
<%= hidden_field_tag 'track_medium', "delete", { :id => 'track_medium_' + track_thing.id.to_s } %>
<%= hidden_field_tag 'r', request.fullpath, { :id => 'r_' + track_thing.id.to_s } %>
<%= submit_tag _('unsubscribe') %>