aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/images/favicon.icobin0 -> 22382 bytes
-rw-r--r--app/assets/images/small-green-cross.pngbin0 -> 356 bytes
-rw-r--r--app/assets/javascripts/general.js75
-rw-r--r--app/assets/stylesheets/admin.scss8
-rw-r--r--app/assets/stylesheets/main.scss62
-rw-r--r--app/controllers/admin_general_controller.rb13
-rw-r--r--app/controllers/admin_public_body_change_requests_controller.rb15
-rw-r--r--app/controllers/admin_public_body_controller.rb44
-rw-r--r--app/controllers/admin_request_controller.rb19
-rw-r--r--app/controllers/api_controller.rb5
-rw-r--r--app/controllers/application_controller.rb94
-rw-r--r--app/controllers/general_controller.rb6
-rw-r--r--app/controllers/public_body_change_requests_controller.rb28
-rw-r--r--app/controllers/public_body_controller.rb2
-rw-r--r--app/controllers/request_controller.rb14
-rw-r--r--app/controllers/services_controller.rb3
-rw-r--r--app/helpers/application_helper.rb13
-rwxr-xr-xapp/helpers/link_to_helper.rb25
-rw-r--r--app/mailers/contact_mailer.rb27
-rw-r--r--app/mailers/request_mailer.rb3
-rw-r--r--app/models/incoming_message.rb4
-rw-r--r--app/models/info_request.rb31
-rw-r--r--app/models/info_request_event.rb4
-rw-r--r--app/models/profile_photo.rb12
-rw-r--r--app/models/public_body.rb64
-rw-r--r--app/models/public_body_change_request.rb130
-rw-r--r--app/views/admin_general/_change_request_summary.html.erb60
-rw-r--r--app/views/admin_general/index.html.erb32
-rw-r--r--app/views/admin_public_body/_form.html.erb18
-rw-r--r--app/views/admin_public_body/new.html.erb4
-rw-r--r--app/views/admin_public_body/show.html.erb5
-rw-r--r--app/views/admin_public_body_change_requests/_response.html.erb15
-rw-r--r--app/views/admin_public_body_change_requests/add_accepted.txt.erb9
-rw-r--r--app/views/admin_public_body_change_requests/edit.html.erb8
-rw-r--r--app/views/admin_public_body_change_requests/update_accepted.txt.erb7
-rw-r--r--app/views/admin_request/_some_annotations.html.erb48
-rw-r--r--app/views/admin_request/show.html.erb49
-rw-r--r--app/views/admin_user/show.html.erb6
-rw-r--r--app/views/comment/_single_comment.html.erb4
-rw-r--r--app/views/contact_mailer/add_public_body.text.erb19
-rw-r--r--app/views/contact_mailer/from_admin_message.text.erb1
-rw-r--r--app/views/contact_mailer/update_public_body_email.text.erb16
-rw-r--r--app/views/general/_footer.html.erb2
-rw-r--r--app/views/general/_localised_datepicker.html.erb10
-rw-r--r--app/views/general/_stylesheet_includes.html.erb2
-rw-r--r--app/views/general/_topnav.html.erb2
-rw-r--r--app/views/help/api.html.erb10
-rw-r--r--app/views/help/privacy.html.erb5
-rw-r--r--app/views/help/requesting.html.erb2
-rw-r--r--app/views/layouts/_favicon.html.erb2
-rw-r--r--app/views/layouts/default.html.erb23
-rw-r--r--app/views/layouts/no_chrome.html.erb1
-rw-r--r--app/views/outgoing_mailer/initial_request.text.erb2
-rw-r--r--app/views/public_body/show.html.erb1
-rw-r--r--app/views/public_body_change_requests/new.html.erb61
-rw-r--r--app/views/reports/new.html.erb8
-rw-r--r--app/views/request/_act.html.erb15
-rw-r--r--app/views/request/_bubble.html.erb2
-rw-r--r--app/views/request/_list_results.html.erb12
-rw-r--r--app/views/request/_sidebar.html.erb17
-rw-r--r--app/views/request/_view_html_prefix.html.erb4
-rw-r--r--app/views/request/_view_html_stylesheet.html.erb2
-rw-r--r--app/views/request/list.html.erb22
-rw-r--r--app/views/request/show.html.erb6
-rw-r--r--app/views/user/sign.html.erb2
-rw-r--r--app/views/user/wall.html.erb25
66 files changed, 870 insertions, 370 deletions
diff --git a/app/assets/images/favicon.ico b/app/assets/images/favicon.ico
new file mode 100644
index 000000000..26127495c
--- /dev/null
+++ b/app/assets/images/favicon.ico
Binary files differ
diff --git a/app/assets/images/small-green-cross.png b/app/assets/images/small-green-cross.png
new file mode 100644
index 000000000..5868f5775
--- /dev/null
+++ b/app/assets/images/small-green-cross.png
Binary files differ
diff --git a/app/assets/javascripts/general.js b/app/assets/javascripts/general.js
index b52131b83..529bbeb04 100644
--- a/app/assets/javascripts/general.js
+++ b/app/assets/javascripts/general.js
@@ -2,49 +2,56 @@ $(document).ready(function() {
// flash message for people coming from other countries
if(window.location.search.substring(1).search("country_name") == -1) {
if (!$.cookie('has_seen_country_message')) {
- $.ajax({
- url: "/country_message",
- dataType: 'html',
- success: function(country_message){
- if (country_message != ''){
- $('#other-country-notice').html(country_message);
- $('body:not(.front) #other-country-notice').show()
- }
- }
- })
+ $.ajax({
+ url: "/country_message",
+ dataType: 'html',
+ success: function(country_message){
+ if (country_message != ''){
+ $('#other-country-notice .popup-content').html(country_message);
+ $('body:not(.front) #other-country-notice').show()
+ }
+ }
+ })
}
}
- $('#other-country-notice').click(function() {
- $('#other-country-notice').hide();
- $.cookie('has_seen_country_message', 1, {expires: 365, path: '/'});
+ // popup messages
+ $('#other-country-notice .popup-close').click(function() {
+ $('#other-country-notice').hide('slow');
+ $.cookie('has_seen_country_message', 1, {expires: 365, path: '/'});
});
+ $('#everypage .popup-close').click(function() {
+ $('#everypage').hide('slow');
+ $.cookie('seen_foi2', 1, { expires: 7, path: '/' });
+ return false;
+ });
+
// "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");
- box.find('input').val(location).attr('size', location.length + " em");
- box.show();
- box.find('input').select();
- box.position({
- my: "left top",
- at: "left bottom",
- of: this,
- collision: "fit" });
- return false;
- });
-
+ var box = $('div#link_box');
+ var location = window.location.protocol + "//" + window.location.hostname + $(this).attr('href');
+ box.width(location.length + " em");
+ box.find('input').val(location).attr('size', location.length + " em");
+ box.show();
+ box.find('input').select();
+ box.position({
+ my: "left top",
+ at: "left bottom",
+ of: this,
+ collision: "fit" });
+ return false;
+ });
+
$('.close-button').click(function() { $(this).parent().hide() });
$('div#variety-filter a').each(function() {
- $(this).click(function() {
- var form = $('form#search_form');
- form.attr('action', $(this).attr('href'));
- form.submit();
- return false;
- })
- })
+ $(this).click(function() {
+ var form = $('form#search_form');
+ form.attr('action', $(this).attr('href'));
+ form.submit();
+ return false;
+ })
+ })
if($.cookie('seen_foi2') == 1) {
$('#everypage').hide();
diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss
index 584b0d00d..b0de2eb7b 100644
--- a/app/assets/stylesheets/admin.scss
+++ b/app/assets/stylesheets/admin.scss
@@ -22,12 +22,8 @@ body.admin {
/* When the admin stylesheet is loaded (and so the user is seeing the admin navbar), pad the banner of the front end interface so that it isn't hidden, and move any special notice down too.
*/
-.entirebody, #banner {
- padding-top: 50px;
-}
-
-#special-notice {
- margin-top: 50px;
+.entirebody {
+ padding-top: 42px;
}
.admin {
diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss
index 7d004e768..3118eab3d 100644
--- a/app/assets/stylesheets/main.scss
+++ b/app/assets/stylesheets/main.scss
@@ -8,7 +8,6 @@ padding:0;
}
#banner {
-position:absolute;
top:0;
background-color:#F3F3F3;
left:0;
@@ -121,7 +120,6 @@ clear:both;
top:0;
text-align:left;
overflow:visible;
-padding-top:160px;
width:900px;
margin:0 auto 1.2em;
}
@@ -719,28 +717,45 @@ margin:60px 0 0;
padding:0.5em 0;
}
-#everypage {
-background-color:#fc9;
-border:solid 2px #f60;
-border-top:none;
-opacity:0.97;
-border-bottom-left-radius:10px;
-border-bottom-right-radius:10px;
-position:fixed;
-width:70%;
-left:15%;
+.popup {
+background-color:#D5FFD8;
+border:solid 3px #16C132;
z-index:2000;
-max-height:95%;
overflow:auto;
-padding:4px;
+text-align:center;
+margin-top:2px;
+}
+
+.popup .popup-content{
+margin:0.5em;
+width: 95%;
+float: left;
+}
+
+.popup p {
+margin: 0;
}
#everypage h2,#everypage h3 {
margin:0.5em 0;
}
-#everypage .popup-close {
- text-align: right;
+
+.popup .popup-close {
+color:#FFF;
+text-decoration:none;
+display:inline-block;
+border-radius:2px;
+-moz-border-radius:2px;
+cursor:pointer;
+background: image-url('small-green-cross.png') no-repeat 0;
+width:15px;
+height:15px;
+border:solid 0 #FFF;
+text-indent:-999px;
+overflow:hidden;
+float:right;
+padding:10px 0;
}
#game_sidebar {
@@ -1568,17 +1583,6 @@ cursor:pointer;
opacity:1;
}
-#other-country-notice {
-background:#222;
-color:#FFF;
-font-size:1.1em;
-width:100%;
-z-index:999;
-display:block;
-position:absolute;
-top:0;
-opacity:0.9;
-}
p.public-body-name-prefix {
color:#888;
@@ -1587,10 +1591,6 @@ margin-bottom:-15px;
font-size: 1.2em;
}
-#other-country-notice a {
-color:#FFF;
-}
-
.close-button {
color:#FFF;
text-decoration:none;
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb
index 196616ed6..753208c9a 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.rb
@@ -27,13 +27,16 @@ class AdminGeneralController < AdminController
@comment_count = Comment.count
# Tasks to do
- @requires_admin_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'requires_admin'"], :order => "last_event_time")
- @error_message_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'error_message'"], :order => "last_event_time")
- @attention_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'attention_requested'"], :order => "last_event_time")
- @blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"], :order => "updated_at")
+ @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")
@old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,
- :conditions => ["prominence = 'normal'"])
+ :conditions => ["prominence = 'normal'"])
@holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
+ @new_body_requests = PublicBodyChangeRequest.new_body_requests.open
+ @body_update_requests = PublicBodyChangeRequest.body_update_requests.open
end
def timeline
diff --git a/app/controllers/admin_public_body_change_requests_controller.rb b/app/controllers/admin_public_body_change_requests_controller.rb
new file mode 100644
index 000000000..d76cdc0e5
--- /dev/null
+++ b/app/controllers/admin_public_body_change_requests_controller.rb
@@ -0,0 +1,15 @@
+class AdminPublicBodyChangeRequestsController < AdminController
+
+ def edit
+ @change_request = PublicBodyChangeRequest.find(params[:id])
+ end
+
+ def update
+ @change_request = PublicBodyChangeRequest.find(params[:id])
+ @change_request.close!
+ @change_request.send_response(params[:subject], params[:response])
+ flash[:notice] = 'The change request has been closed and the user has been notified'
+ redirect_to admin_general_index_path
+ end
+
+end
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index e0da234b0..120419a27 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -85,14 +85,33 @@ class AdminPublicBodyController < AdminController
def new
@public_body = PublicBody.new
- render
+ if params[:change_request_id]
+ @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
+ end
+ if @change_request
+ @change_request_user_response = render_to_string(:template => "admin_public_body_change_requests/add_accepted",
+ :formats => [:txt])
+ @public_body.name = @change_request.public_body_name
+ @public_body.request_email = @change_request.public_body_email
+ @public_body.last_edit_comment = @change_request.comment_for_public_body
+ end
+ render :formats => [:html]
end
def create
I18n.with_locale(I18n.default_locale) do
+ if params[:change_request_id]
+ @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
+ end
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
+ if @change_request
+ response_text = params[:response].gsub(_("[Authority URL will be inserted here]"),
+ public_body_url(@public_body, :only_path => false))
+ @change_request.close!
+ @change_request.send_response(params[:subject], response_text)
+ end
flash[:notice] = 'PublicBody was successfully created.'
redirect_to admin_body_show_url(@public_body)
else
@@ -103,15 +122,32 @@ class AdminPublicBodyController < AdminController
def edit
@public_body = PublicBody.find(params[:id])
- @public_body.last_edit_comment = ""
- render
+ if params[:change_request_id]
+ @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
+ end
+ if @change_request
+ @change_request_user_response = render_to_string(:template => "admin_public_body_change_requests/update_accepted",
+ :formats => [:txt])
+ @public_body.request_email = @change_request.public_body_email
+ @public_body.last_edit_comment = @change_request.comment_for_public_body
+ else
+ @public_body.last_edit_comment = ""
+ end
+ render :formats => [:html]
end
def update
+ if params[:change_request_id]
+ @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
+ end
I18n.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
+ if @change_request
+ @change_request.close!
+ @change_request.send_response(params[:subject], params[:response])
+ end
flash[:notice] = 'PublicBody was successfully updated.'
redirect_to admin_body_show_url(@public_body)
else
@@ -143,6 +179,8 @@ class AdminPublicBodyController < AdminController
@errors = ""
if request.post?
dry_run_only = (params['commit'] == 'Upload' ? false : true)
+ # (FIXME: both of these cases could now be changed to use
+ # PublicBody.import_csv_from_file.)
# Read file from params
if params[:csv_file]
csv_contents = params[:csv_file].read
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 4d45ced8b..fc291d998 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -26,15 +26,13 @@ class AdminRequestController < AdminController
def show
@info_request = InfoRequest.find(params[:id])
- # XXX is this *really* the only way to render a template to a
- # variable, rather than to the response?
- vars = OpenStruct.new(:name_to => @info_request.user_name,
- :name_from => AlaveteliConfiguration::contact_name,
- :info_request => @info_request, :reason => params[:reason],
- :info_request_url => 'http://' + AlaveteliConfiguration::domain + request_url(@info_request),
- :site_name => site_name)
- template = File.read(File.join(File.dirname(__FILE__), "..", "views", "admin_request", "hidden_user_explanation.html.erb"))
- @request_hidden_user_explanation = ERB.new(template).result(vars.instance_eval { binding })
+ vars_for_explanation = {:reason => params[:reason],
+ :info_request => @info_request,
+ :name_to => @info_request.user_name,
+ :name_from => AlaveteliConfiguration::contact_name,
+ :info_request_url => request_url(@info_request, :only_path => false)}
+ @request_hidden_user_explanation = render_to_string(:template => "admin_request/hidden_user_explanation",
+ :locals => vars_for_explanation)
end
def resend
@@ -281,7 +279,8 @@ class AdminRequestController < AdminController
if ! info_request.is_external?
ContactMailer.from_admin_message(
- info_request.user,
+ info_request.user.name,
+ info_request.user.email,
subject,
params[:explanation].strip.html_safe
).deliver
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 00a3beebd..e6b0c121a 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -16,11 +16,14 @@ class ApiController < ApplicationController
:status => @request.calculate_status,
:public_body_url => make_url("body", @request.public_body.url_name),
- :requestor_url => make_url("user", @request.user.url_name),
+
:request_email => @request.incoming_email,
:request_text => @request.last_event_forming_initial_request.outgoing_message.body,
}
+ if @request.user
+ @request_data[:requestor_url] = make_url("user", @request.user.url_name)
+ end
render :json => @request_data
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index ff21cb114..370e8e15c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -428,100 +428,6 @@ class ApplicationController < ActionController::Base
end
end
- def get_request_variety_from_params(params)
- query = ""
- sortby = "newest"
- varieties = []
- if params[:request_variety] && !(query =~ /variety:/)
- if params[:request_variety].include? "sent"
- varieties -= ['variety:sent', 'variety:followup_sent', 'variety:response', 'variety:comment']
- varieties << ['variety:sent', 'variety:followup_sent']
- end
- if params[:request_variety].include? "response"
- varieties << ['variety:response']
- end
- if params[:request_variety].include? "comment"
- varieties << ['variety:comment']
- end
- end
- if !varieties.empty?
- query = " (#{varieties.join(' OR ')})"
- end
- return query
- end
-
- def get_status_from_params(params)
- query = ""
- if params[:latest_status]
- statuses = []
- if params[:latest_status].class == String
- params[:latest_status] = [params[:latest_status]]
- end
- if params[:latest_status].include?("recent") || params[:latest_status].include?("all")
- query += " (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)"
- end
- if params[:latest_status].include? "successful"
- statuses << ['latest_status:successful', 'latest_status:partially_successful']
- end
- if params[:latest_status].include? "unsuccessful"
- statuses << ['latest_status:rejected', 'latest_status:not_held']
- end
- if params[:latest_status].include? "awaiting"
- statuses << ['latest_status:waiting_response', 'latest_status:waiting_clarification', 'waiting_classification:true', 'latest_status:internal_review','latest_status:gone_postal', 'latest_status:error_message', 'latest_status:requires_admin']
- end
- if params[:latest_status].include? "internal_review"
- statuses << ['status:internal_review']
- end
- if params[:latest_status].include? "other"
- statuses << ['latest_status:gone_postal', 'latest_status:error_message', 'latest_status:requires_admin', 'latest_status:user_withdrawn']
- end
- if params[:latest_status].include? "gone_postal"
- statuses << ['latest_status:gone_postal']
- end
- if !statuses.empty?
- query = " (#{statuses.join(' OR ')})"
- end
- end
- return query
- end
-
- def get_date_range_from_params(params)
- query = ""
- if params.has_key?(:request_date_after) && !params.has_key?(:request_date_before)
- params[:request_date_before] = Time.now.strftime("%d/%m/%Y")
- query += " #{params[:request_date_after]}..#{params[:request_date_before]}"
- elsif !params.has_key?(:request_date_after) && params.has_key?(:request_date_before)
- params[:request_date_after] = "01/01/2001"
- end
- if params.has_key?(:request_date_after)
- query = " #{params[:request_date_after]}..#{params[:request_date_before]}"
- end
- return query
- end
-
- def get_tags_from_params(params)
- query = ""
- tags = []
- if params.has_key?(:tags)
- params[:tags].split().each do |tag|
- tags << "tag:#{tag}"
- end
- end
- if !tags.empty?
- query = " (#{tags.join(' OR ')})"
- end
- return query
- end
-
- def make_query_from_params(params)
- query = params[:query] || "" if query.nil?
- query += get_date_range_from_params(params)
- query += get_request_variety_from_params(params)
- query += get_status_from_params(params)
- query += get_tags_from_params(params)
- return query
- end
-
def country_from_ip
country = ""
if !AlaveteliConfiguration::gaze_url.empty?
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index aac078829..6f0d29889 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -17,6 +17,10 @@ class GeneralController < ApplicationController
# Display blog entries
def blog
+ if AlaveteliConfiguration::blog_feed.empty?
+ raise ActiveRecord::RecordNotFound.new("Page not enabled")
+ end
+
medium_cache
@feed_autodetect = []
@feed_url = AlaveteliConfiguration::blog_feed
@@ -99,7 +103,7 @@ class GeneralController < ApplicationController
params[:query] = @query
end
if @variety_postfix != "all" && @requests
- @query, _ = make_query_from_params(params)
+ @query = InfoRequestEvent.make_query_from_params(params)
end
@inputted_sortby = @sortby
if @sortby.nil?
diff --git a/app/controllers/public_body_change_requests_controller.rb b/app/controllers/public_body_change_requests_controller.rb
new file mode 100644
index 000000000..4a6c5f5cb
--- /dev/null
+++ b/app/controllers/public_body_change_requests_controller.rb
@@ -0,0 +1,28 @@
+class PublicBodyChangeRequestsController < ApplicationController
+
+ def create
+ @change_request = PublicBodyChangeRequest.from_params(params[:public_body_change_request], @user)
+ if @change_request.save
+ @change_request.send_message
+ flash[:notice] = @change_request.thanks_notice
+ redirect_to frontpage_url
+ return
+ else
+ render :action => 'new'
+ end
+ end
+
+ def new
+ @change_request = PublicBodyChangeRequest.new
+ if params[:body]
+ @change_request.public_body = PublicBody.find_by_url_name_with_historic(params[:body])
+ end
+ if @change_request.public_body
+ @title = _('Ask us to update the email address for {{public_body_name}}',
+ :public_body_name => @change_request.public_body.name)
+ else
+ @title = _('Ask us to add an authority')
+ end
+
+ end
+end
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 308d38e4c..862f4b318 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -40,7 +40,7 @@ class PublicBodyController < ApplicationController
@searched_to_send_request = true
end
@view = params[:view]
- query = make_query_from_params(params.merge(:latest_status => @view))
+ query = InfoRequestEvent.make_query_from_params(params.merge(:latest_status => @view))
query += " requested_from:#{@public_body.url_name}"
# Use search query for this so can collapse and paginate easily
# XXX really should just use SQL query here rather than Xapian.
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 391670715..a94461758 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -167,7 +167,10 @@ class RequestController < ApplicationController
def list
medium_cache
@view = params[:view]
+ @locale = self.locale_from_params()
@page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect
+ @per_page = PER_PAGE
+ @max_results = MAX_RESULTS
if @view == "recent"
return redirect_to request_list_all_url(:action => "list", :view => "all", :page => @page), :status => :moved_permanently
end
@@ -177,16 +180,11 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / PER_PAGE}.")
end
- query = make_query_from_params(params.merge(:latest_status => @view))
+ @filters = params.merge(:latest_status => @view)
@title = _("View and search requests")
- sortby = "newest"
- xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
- @list_results = xapian_object.results.map { |r| r[:model] }
- @matches_estimated = xapian_object.matches_estimated
- @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated
@title = @title + " (page " + @page.to_s + ")" if (@page > 1)
- @track_thing = TrackThing.create_track_for_search_query(query)
+ @track_thing = TrackThing.create_track_for_search_query(InfoRequestEvent.make_query_from_params(@filters))
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ]
# Don't let robots go more than 20 pages in
@@ -346,7 +344,7 @@ class RequestController < ApplicationController
if !authenticated?(
:web => _("To send your FOI request").to_str,
:email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name),
- :email_subject => _("Confirm your FOI request to ") + @info_request.public_body.name
+ :email_subject => _("Confirm your FOI request to {{public_body_name}}",:public_body_name=>@info_request.public_body.name)
)
# do nothing - as "authenticated?" has done the redirect to signin page for us
return
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index 11ed4ac8f..78c494dba 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -24,9 +24,6 @@ class ServicesController < ApplicationController
FastGettext.locale = old_fgt_locale
end
end
- if !text.empty?
- text += ' <span class="close-button">X</span>'.html_safe
- end
render :text => text, :content_type => "text/plain" # XXX workaround the HTML validation in test suite
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4b603b064..154697377 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -123,5 +123,18 @@ module ApplicationHelper
yield
end
end
+
+ # We only want to cache request lists that have a reasonable chance of not expiring
+ # before they're requested again. Don't cache lists returned from specific searches
+ # or anything except the first page of results, just the first page of the default
+ # views
+ def request_list_cache_key
+ cacheable_param_list = ['controller', 'action', 'locale', 'view']
+ if params.keys.all?{ |key| cacheable_param_list.include?(key) }
+ "request-list-#{@view}-#{@locale}"
+ else
+ nil
+ end
+ end
end
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 8df28f350..405886a85 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -121,24 +121,37 @@ module LinkToHelper
end
def user_link_absolute(user)
- link_to h(user.name), user_url(user)
+ link_to user.name, user_url(user)
end
def user_link(user)
- link_to h(user.name), user_path(user)
+ link_to user.name, user_path(user)
end
- def request_user_link_absolute(request)
+ def external_user_link(request, absolute, text)
+ if request.external_user_name
+ request.external_user_name
+ else
+ if absolute
+ url = help_privacy_url(:anchor => 'anonymous')
+ else
+ url = help_privacy_path(:anchor => 'anonymous')
+ end
+ link_to(text, url)
+ end
+ end
+
+ def request_user_link_absolute(request, anonymous_text=_("Anonymous user"))
if request.is_external?
- request.external_user_name || _("Anonymous user")
+ external_user_link(request, absolute=true, anonymous_text)
else
user_link_absolute(request.user)
end
end
- def request_user_link(request)
+ def request_user_link(request, anonymous_text=_("Anonymous user"))
if request.is_external?
- request.external_user_name || _("Anonymous user")
+ external_user_link(request, absolute=false, anonymous_text)
else
user_link(request.user)
end
diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb
index 4dc49bf8b..27e04ca4b 100644
--- a/app/mailers/contact_mailer.rb
+++ b/app/mailers/contact_mailer.rb
@@ -34,12 +34,31 @@ class ContactMailer < ApplicationMailer
end
# Send message to a user from the administrator
- def from_admin_message(recipient_user, subject, message)
- @message, @from_user, @recipient_user = message, contact_from_name_and_email, recipient_user
-
+ def from_admin_message(recipient_name, recipient_email, subject, message)
+ @message, @from_user = message, contact_from_name_and_email
+ @recipient_name, @recipient_email = recipient_name, recipient_email
mail(:from => contact_from_name_and_email,
- :to => recipient_user.name_and_email,
+ :to => MailHandler.address_from_name_and_email(@recipient_name, @recipient_email),
:bcc => AlaveteliConfiguration::contact_email,
:subject => subject)
end
+
+ # Send a request to the administrator to add an authority
+ def add_public_body(change_request)
+ @change_request = change_request
+ mail(:from => MailHandler.address_from_name_and_email(@change_request.get_user_name, @change_request.get_user_email),
+ :to => contact_from_name_and_email,
+ :subject => _('Add authority - {{public_body_name}}',
+ :public_body_name => @change_request.get_public_body_name))
+ end
+
+ # Send a request to the administrator to update an authority email address
+ def update_public_body_email(change_request)
+ @change_request = change_request
+ mail(:from => MailHandler.address_from_name_and_email(@change_request.get_user_name, @change_request.get_user_email),
+ :to => contact_from_name_and_email,
+ :subject => _('Update email address - {{public_body_name}}',
+ :public_body_name => @change_request.get_public_body_name))
+ end
+
end
diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb
index c8a19afa8..af1a75df9 100644
--- a/app/mailers/request_mailer.rb
+++ b/app/mailers/request_mailer.rb
@@ -19,7 +19,8 @@ class RequestMailer < ApplicationMailer
end
mail(:from => from_user.name_and_email,
- :to => info_request.incoming_name_and_email)
+ :to => info_request.incoming_name_and_email,
+ :subject => info_request.email_subject_followup)
end
# Used when a response is uploaded using the API
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index bcf0b6ec9..59e61952e 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -385,6 +385,10 @@ class IncomingMessage < ActiveRecord::Base
multiline_original_message = '(' + '''>>>.* \d\d/\d\d/\d\d\d\d\s+\d\d:\d\d(?::\d\d)?\s*>>>''' + ')'
text.gsub!(/^(#{multiline_original_message}\n.*)$/m, replacement)
+ # On Thu, Nov 28, 2013 at 9:08 AM, A User
+ # <[1]request-7-skm40s2ls@xxx.xxxx> wrote:
+ text.gsub!(/^( On [^\n]+\n\s*\<[^>\n]+\> (wrote|said):\s*\n.*)$/m, replacement)
+
# Single line sections
text.gsub!(/^(>.*\n)/, replacement)
text.gsub!(/^(On .+ (wrote|said):\n)/, replacement)
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index c95b7427e..47ad435cb 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -117,8 +117,12 @@ class InfoRequest < ActiveRecord::Base
# Possible reasons that a request could be reported for administrator attention
def report_reasons
- ["Contains defamatory material", "Not a valid request", "Request for personal information",
- "Contains personal information", "Vexatious", "Other"]
+ [_("Contains defamatory material"),
+ _("Not a valid request"),
+ _("Request for personal information"),
+ _("Contains personal information"),
+ _("Vexatious"),
+ _("Other")]
end
def must_be_valid_state
@@ -1253,6 +1257,23 @@ public
return [xapian_similar, xapian_similar_more]
end
+ def InfoRequest.request_list(filters, page, per_page, max_results)
+ xapian_object = ActsAsXapian::Search.new([InfoRequestEvent],
+ InfoRequestEvent.make_query_from_params(filters),
+ :offset => (page - 1) * per_page,
+ :limit => 25,
+ :sort_by_prefix => 'created_at',
+ :sort_by_ascending => true,
+ :collapse_by_prefix => 'request_collapse'
+ )
+ list_results = xapian_object.results.map { |r| r[:model] }
+ matches_estimated = xapian_object.matches_estimated
+ show_no_more_than = [matches_estimated, max_results].min
+ return { :results => list_results,
+ :matches_estimated => matches_estimated,
+ :show_no_more_than => show_no_more_than }
+ end
+
def InfoRequest.recent_requests
request_events = []
request_events_all_successful = false
@@ -1300,6 +1321,12 @@ public
return [request_events, request_events_all_successful]
end
+ def InfoRequest.find_in_state(state)
+ find(:all, :select => '*, ' + last_event_time_clause + ' as last_event_time',
+ :conditions => ["described_state = ?", state],
+ :order => "last_event_time")
+ end
+
private
def set_defaults
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index e268b28ca..5eed5ba83 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -21,6 +21,9 @@
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class InfoRequestEvent < ActiveRecord::Base
+
+ extend XapianQueries
+
belongs_to :info_request
validates_presence_of :info_request
@@ -416,4 +419,5 @@ class InfoRequestEvent < ActiveRecord::Base
yield(column.human_name, self.send(column.name), column.type.to_s, column.name)
end
end
+
end
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb
index 322ebe53c..6c3b2cfa0 100644
--- a/app/models/profile_photo.rb
+++ b/app/models/profile_photo.rb
@@ -70,21 +70,25 @@ class ProfilePhoto < ActiveRecord::Base
def data_and_draft_checks
if self.data.nil?
- errors.add(:data, N_("Please choose a file containing your photo."))
+ errors.add(:data, _("Please choose a file containing your photo."))
return
end
if self.image.nil?
- errors.add(:data, N_("Couldn't understand the image file that you uploaded. PNG, JPEG, GIF and many other common image file formats are supported."))
+ errors.add(:data, _("Couldn't understand the image file that you uploaded. PNG, JPEG, GIF and many other common image file formats are supported."))
return
end
if self.image.format != 'PNG'
- errors.add(:data, N_("Failed to convert image to a PNG"))
+ errors.add(:data, _("Failed to convert image to a PNG"))
end
if !self.draft && (self.image.columns != WIDTH || self.image.rows != HEIGHT)
- errors.add(:data, N_("Failed to convert image to the correct size: at {{cols}}x{{rows}}, need {{width}}x{{height}}", :cols => self.image.columns, :rows => self.image.rows, :width => WIDTH, :height => HEIGHT))
+ errors.add(:data, _("Failed to convert image to the correct size: at {{cols}}x{{rows}}, need {{width}}x{{height}}",
+ :cols => self.image.columns,
+ :rows => self.image.rows,
+ :width => WIDTH,
+ :height => HEIGHT))
end
if self.draft && self.user_id
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 2939a7f29..7b1ded820 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -261,13 +261,13 @@ class PublicBody < ActiveRecord::Base
# When name or short name is changed, also change the url name
def short_name=(short_name)
- globalize.write(I18n.locale, :short_name, short_name)
+ globalize.write(Globalize.locale, :short_name, short_name)
self[:short_name] = short_name
self.update_url_name
end
def name=(name)
- globalize.write(I18n.locale, :name, name)
+ globalize.write(Globalize.locale, :name, name)
self[:name] = name
self.update_url_name
end
@@ -347,22 +347,26 @@ class PublicBody < ActiveRecord::Base
# The "internal admin" is a special body for internal use.
def PublicBody.internal_admin_body
- I18n.with_locale(I18n.default_locale) do
- pb = PublicBody.find_by_url_name("internal_admin_authority")
- if pb.nil?
- pb = PublicBody.new(
- :name => 'Internal admin authority',
- :short_name => "",
- :request_email => AlaveteliConfiguration::contact_email,
- :home_page => "",
- :notes => "",
- :publication_scheme => "",
- :last_edit_editor => "internal_admin",
- :last_edit_comment => "Made by PublicBody.internal_admin_body"
- )
- pb.save!
+ # Use find_by_sql to avoid the search being specific to a
+ # locale, since url_name is a translated field:
+ sql = "SELECT * FROM public_bodies WHERE url_name = 'internal_admin_authority'"
+ matching_pbs = PublicBody.find_by_sql sql
+ case
+ when matching_pbs.empty? then
+ I18n.with_locale(I18n.default_locale) do
+ PublicBody.create!(:name => 'Internal admin authority',
+ :short_name => "",
+ :request_email => AlaveteliConfiguration::contact_email,
+ :home_page => "",
+ :notes => "",
+ :publication_scheme => "",
+ :last_edit_editor => "internal_admin",
+ :last_edit_comment => "Made by PublicBody.internal_admin_body")
end
- return pb
+ when matching_pbs.length == 1 then
+ matching_pbs[0]
+ else
+ raise "Multiple public bodies (#{matching_pbs.length}) found with url_name 'internal_admin_authority'"
end
end
@@ -370,10 +374,24 @@ class PublicBody < ActiveRecord::Base
class ImportCSVDryRun < StandardError
end
- # Import from CSV. Just tests things and returns messages if dry_run is true.
- # Returns an array of [array of errors, array of notes]. If there are errors,
- # always rolls back (as with dry_run).
+ # Import from a string in CSV format.
+ # Just tests things and returns messages if dry_run is true.
+ # Returns an array of [array of errors, array of notes]. If there
+ # are errors, always rolls back (as with dry_run).
def self.import_csv(csv, tag, tag_behaviour, dry_run, editor, available_locales = [])
+ tmp_csv = nil
+ Tempfile.open('alaveteli') do |f|
+ f.write csv
+ tmp_csv = f
+ end
+ PublicBody.import_csv_from_file(tmp_csv.path, tag, tag_behaviour, dry_run, editor, available_locales)
+ end
+
+ # Import from a CSV file.
+ # Just tests things and returns messages if dry_run is true.
+ # Returns an array of [array of errors, array of notes]. If there
+ # are errors, always rolls back (as with dry_run).
+ def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, available_locales = [])
errors = []
notes = []
available_locales = [I18n.default_locale] if available_locales.empty?
@@ -399,7 +417,8 @@ class PublicBody < ActiveRecord::Base
set_of_importing = Set.new()
field_names = { 'name'=>1, 'request_email'=>2 } # Default values in case no field list is given
line = 0
- CSV.parse(csv) do |row|
+
+ CSV.foreach(csv_filename) do |row|
line = line + 1
# Parse the first line as a field list if it starts with '#'
@@ -728,7 +747,8 @@ class PublicBody < ActiveRecord::Base
# either from config, or based on a (slow!) query if not set
body_short_names = AlaveteliConfiguration::frontpage_publicbody_examples.split(/\s*;\s*/)
locale_condition = 'public_body_translations.locale = ?'
- conditions = [locale_condition, locale]
+ underscore_locale = locale.gsub '-', '_'
+ conditions = [locale_condition, underscore_locale]
bodies = []
I18n.with_locale(locale) do
if body_short_names.empty?
diff --git a/app/models/public_body_change_request.rb b/app/models/public_body_change_request.rb
new file mode 100644
index 000000000..c1f395c0c
--- /dev/null
+++ b/app/models/public_body_change_request.rb
@@ -0,0 +1,130 @@
+# == Schema Information
+#
+# Table name: public_body_change_requests
+#
+# id :integer not null, primary key
+# user_email :string(255)
+# user_name :string(255)
+# user_id :integer
+# public_body_name :text
+# public_body_id :integer
+# public_body_email :string(255)
+# source_url :text
+# notes :text
+# is_open :boolean default(TRUE), not null
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
+class PublicBodyChangeRequest < ActiveRecord::Base
+
+ belongs_to :user
+ belongs_to :public_body
+ validates_presence_of :public_body_name, :message => N_("Please enter the name of the authority"),
+ :unless => proc{ |change_request| change_request.public_body }
+ validates_presence_of :user_name, :message => N_("Please enter your name"),
+ :unless => proc{ |change_request| change_request.user }
+ validates_presence_of :user_email, :message => N_("Please enter your email address"),
+ :unless => proc{ |change_request| change_request.user }
+ validate :user_email_format, :unless => proc{ |change_request| change_request.user_email.blank? }
+ validate :body_email_format, :unless => proc{ |change_request| change_request.public_body_email.blank? }
+
+ scope :new_body_requests, :conditions => ['public_body_id IS NULL'], :order => 'created_at'
+ scope :body_update_requests, :conditions => ['public_body_id IS NOT NULL'], :order => 'created_at'
+ scope :open, :conditions => ['is_open = ?', true]
+
+ def self.from_params(params, user)
+ change_request = new
+ change_request.update_from_params(params, user)
+ end
+
+ def update_from_params(params, user)
+ if user
+ self.user_id = user.id
+ else
+ self.user_name = params[:user_name]
+ self.user_email = params[:user_email]
+ end
+ self.public_body_name = params[:public_body_name]
+ self.public_body_id = params[:public_body_id]
+ self.public_body_email = params[:public_body_email]
+ self.source_url = params[:source_url]
+ self.notes = params[:notes]
+ self
+ end
+
+ def get_user_name
+ user ? user.name : user_name
+ end
+
+ def get_user_email
+ user ? user.email : user_email
+ end
+
+ def get_public_body_name
+ public_body ? public_body.name : public_body_name
+ end
+
+ def send_message
+ if public_body
+ ContactMailer.update_public_body_email(self).deliver
+ else
+ ContactMailer.add_public_body(self).deliver
+ end
+ end
+
+ def thanks_notice
+ if self.public_body
+ _("Your request to update the address for #{get_public_body_name} has been sent. Thank you for getting in touch! We'll get back to you soon.")
+ else
+ _("Your request to add an authority has been sent. Thank you for getting in touch! We'll get back to you soon.")
+ end
+ end
+
+ def send_response(subject, response)
+ ContactMailer.from_admin_message(get_user_name,
+ get_user_email,
+ subject,
+ response.strip.html_safe).deliver
+ end
+
+ def comment_for_public_body
+ comments = [_("Requested by: #{get_user_name} (#{get_user_email})")]
+ if !source_url.blank?
+ comments << _("Source URL: #{source_url}")
+ end
+ if !notes.blank?
+ comments << _("Notes: #{notes}")
+ end
+ comments.join("\n")
+ end
+
+ def default_response_subject
+ if self.public_body
+ _("Your request to update {{public_body_name}} on {{site_name}}", :site_name => AlaveteliConfiguration::site_name,
+ :public_body_name => public_body.name)
+ else
+ _("Your request to add {{public_body_name}} to {{site_name}}", :site_name => AlaveteliConfiguration::site_name,
+ :public_body_name => public_body_name)
+ end
+ end
+
+ def close!
+ self.is_open = false
+ self.save!
+ end
+
+ private
+
+ def body_email_format
+ unless MySociety::Validate.is_valid_email(self.public_body_email)
+ errors.add(:public_body_email, _("The authority email doesn't look like a valid address"))
+ end
+ end
+
+ def user_email_format
+ unless MySociety::Validate.is_valid_email(self.user_email)
+ errors.add(:user_email, _("Your email doesn't look like a valid address"))
+ end
+ end
+end
diff --git a/app/views/admin_general/_change_request_summary.html.erb b/app/views/admin_general/_change_request_summary.html.erb
new file mode 100644
index 000000000..bec49c12c
--- /dev/null
+++ b/app/views/admin_general/_change_request_summary.html.erb
@@ -0,0 +1,60 @@
+<table class="table table-striped table-condensed">
+ <tbody>
+ <tr>
+ <td>
+ <b>Authority</b>
+ </td>
+ <td>
+ <%= @change_request.get_public_body_name %>
+ </td>
+ </tr>
+
+ <% if @change_request.public_body %>
+ <tr>
+ <td>
+ <b>Current address</b>
+ </td>
+ <td>
+ <%= @change_request.public_body.request_email %>
+ </td>
+ </tr>
+ <% end %>
+
+ <tr>
+ <td>
+ <b>Suggested address</b>
+ </td>
+ <td>
+ <%= @change_request.public_body_email %>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <b>Source</b>
+ </td>
+ <td>
+ <%= @change_request.source_url %>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <b>Requested by</b>
+ </td>
+ <td>
+ <%= @change_request.get_user_name %> (<%= @change_request.get_user_email %>)
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <b>Requested on</b>
+ </td>
+ <td>
+ <%= I18n.l(@change_request.created_at, :format => "%e %B %Y %H:%M:%S") %>
+ (<%= "#{time_ago_in_words(@change_request.created_at)} ago" %>)
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/app/views/admin_general/index.html.erb b/app/views/admin_general/index.html.erb
index 976860fa7..2202663be 100644
--- a/app/views/admin_general/index.html.erb
+++ b/app/views/admin_general/index.html.erb
@@ -174,9 +174,39 @@
</div>
</div>
<% end %>
+
+ <% if @new_body_requests.size > 0 %>
+ <div class="accordion-group">
+ <div class="accordion-heading">
+ <a class="accordion-toggle" href="#new-authorities" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%= @new_body_requests.size %></span><%= chevron_right %> Add new authorities</a>
+ </div>
+ <div id="new-authorities" class="accordion-body collapse">
+ <% for @change_request in @new_body_requests %>
+ <%= render :partial => 'change_request_summary'%>
+ <%= link_to("Close and respond", admin_change_request_edit_path(@change_request), :class => 'btn') %>
+ <%= link_to("Add authority", admin_body_new_path(:change_request_id => @change_request.id), :class => 'btn btn-primary') %>
+ <% end %>
+ </div>
+ </div>
+ <% end %>
+
+ <% if @body_update_requests.size > 0 %>
+ <div class="accordion-group">
+ <div class="accordion-heading">
+ <a class="accordion-toggle" href="#update-authorities" data-toggle="collapse" data-parent="things-to-do"><span class="label label-important"><%= @body_update_requests.size %></span><%= chevron_right %> Update authorities</a>
+ </div>
+ <div id="update-authorities" class="accordion-body collapse">
+ <% for @change_request in @body_update_requests %>
+ <%= render :partial => 'change_request_summary' %>
+ <%= link_to("Close and respond", admin_change_request_edit_path(@change_request), :class => 'btn') %>
+ <%= link_to("Make update", admin_body_edit_path(@change_request.public_body, :change_request_id => @change_request.id), :class => 'btn btn-primary') %>
+ <% end %>
+ </div>
+ </div>
+ <% end %>
</div>
-<% if @holding_pen_messages.size == 0 && @old_unclassified.size == 0 && @requires_admin_requests.size == 0 && @blank_contacts.size == 0 && @attention_requests.size == 0 %>
+<% if @holding_pen_messages.size == 0 && @old_unclassified.size == 0 && @requires_admin_requests.size == 0 && @blank_contacts.size == 0 && @attention_requests.size == 0 && @new_body_requests.size == 0 && @body_update_requests.size == 0 %>
<div class="row">
<div class="span12 alert alert-success">
No pending administration required.
diff --git a/app/views/admin_public_body/_form.html.erb b/app/views/admin_public_body/_form.html.erb
index c577d1e18..2da13ab01 100644
--- a/app/views/admin_public_body/_form.html.erb
+++ b/app/views/admin_public_body/_form.html.erb
@@ -51,12 +51,6 @@
</div>
</div>
<div class="control-group">
- <label for="<%= form_tag_id(t.object_name, :disclosure_log, locale) %>" class="control-label"><%=_("Disclosure log URL")%></label>
- <div class="controls">
- <%= t.text_field :disclosure_log, :size => 60, :id => form_tag_id(t.object_name, :disclosure_log, locale), :class => "span3" %>
- </div>
- </div>
- <div class="control-group">
<label for="<%= form_tag_id(t.object_name, :notes, locale) %>" class="control-label"><%=_("Public notes")%></label>
<div class="controls">
<%= t.text_area :notes, :rows => 3, :id => form_tag_id(t.object_name, :notes, locale), :class => "span6" %>
@@ -82,17 +76,27 @@
</div>
</div>
<div class="control-group">
- <label for="public_body_home_page"><%=_("Home page")%></label>
+ <label for="public_body_home_page" class="control-label"><%=_("Home page")%></label>
<div class="controls">
<%= f.text_field :home_page, :class => "span4" %>
<p class="help-block">(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</p>
</div>
</div>
<div class="control-group">
+ <label for="public_body_disclosure_log" class="control-label"><%=_("Disclosure log URL")%></label>
+ <div class="controls">
+ <%= f.text_field :disclosure_log, :size => 60, :class => "span4" %>
+ </div>
+</div>
+<div class="control-group">
<label for="public_body_last_edit_comment" class="control-label"><strong>Comment</strong> for this edit</label>
<div class="controls">
<%= f.text_area :last_edit_comment, :rows => 3, :class => "span6" %></p>
<p class="help-block">put URL or other source of new info</p>
</div>
</div>
+<% if @change_request %>
+ <%= render :partial => 'admin_public_body_change_requests/response' %>
+
+<% end %>
<!--[eoform:public_body]-->
diff --git a/app/views/admin_public_body/new.html.erb b/app/views/admin_public_body/new.html.erb
index 13e8238d6..24b27d7af 100644
--- a/app/views/admin_public_body/new.html.erb
+++ b/app/views/admin_public_body/new.html.erb
@@ -6,13 +6,15 @@
<div id="public_body_form">
<%= form_for @public_body, :as => :public_body, :url => admin_body_create_path, :html => {:class => "form form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
+
+
<div class="form-actions">
<%= f.submit "Create", :class => "btn btn-primary" %>
</div>
<% end %>
<div class="row">
<div class="span8 well">
- <%= link_to _('List all'), 'list' %>
+ <%= link_to 'List all', admin_body_list_path, :class => "btn" %>
</div>
</div>
</div>
diff --git a/app/views/admin_public_body/show.html.erb b/app/views/admin_public_body/show.html.erb
index 8262287d5..f8161db26 100644
--- a/app/views/admin_public_body/show.html.erb
+++ b/app/views/admin_public_body/show.html.erb
@@ -67,7 +67,10 @@
</div>
<% if i == versions.length - 1 %>
<div class="span6">
- <%=_("This is the first version.")%>
+ <p>“<%= h(historic_public_body.last_edit_comment) %>”</p>
+ <ul>
+ <li><%=_("This is the first version.")%></li>
+ </ul>
</div>
<% else %>
<div class="span6">
diff --git a/app/views/admin_public_body_change_requests/_response.html.erb b/app/views/admin_public_body_change_requests/_response.html.erb
new file mode 100644
index 000000000..7fda8b7f8
--- /dev/null
+++ b/app/views/admin_public_body_change_requests/_response.html.erb
@@ -0,0 +1,15 @@
+<h3>Response to change request (will be emailed to user):</h3>
+<%= hidden_field_tag 'change_request_id', @change_request.id %>
+<div class="control-group" id="change_request_user_subject">
+ <label for="change_request_user_subject_field" class="control-label">Subject of email:</label>
+ <div class="controls">
+ <%= text_field_tag "subject", (params[:subject] || @change_request.default_response_subject), {:id => "change_request_user_subject_field", :class => "span6"} %>
+ </div>
+</div>
+
+<div class="control-group" id="change_request_user_response">
+ <label for="change_request_user_response_field" class="control-label">Response</label>
+ <div class="controls">
+ <%= text_area_tag "response", (params[:response] || h(@change_request_user_response)), {:id => "change_request_user_response_field", :rows => 10, :class => 'span6'} %>
+ </div>
+</div>
diff --git a/app/views/admin_public_body_change_requests/add_accepted.txt.erb b/app/views/admin_public_body_change_requests/add_accepted.txt.erb
new file mode 100644
index 000000000..fb22466b0
--- /dev/null
+++ b/app/views/admin_public_body_change_requests/add_accepted.txt.erb
@@ -0,0 +1,9 @@
+<%= _("Dear {{user_name}},", :user_name => @change_request.get_user_name) %>
+
+<%= _("Thanks for your suggestion to add {{public_body_name}}. It's been added to the site here:", :public_body_name => @change_request.public_body_name) %>
+
+<%= _("[Authority URL will be inserted here]")%>
+
+<%= _("Yours,") %>
+
+<%= _("The {{site_name}} team.", :site_name => site_name) %>
diff --git a/app/views/admin_public_body_change_requests/edit.html.erb b/app/views/admin_public_body_change_requests/edit.html.erb
new file mode 100644
index 000000000..cc9c5b5d9
--- /dev/null
+++ b/app/views/admin_public_body_change_requests/edit.html.erb
@@ -0,0 +1,8 @@
+<h1><%=@title%></h1>
+
+<%= form_tag admin_change_request_update_path(@change_request), :class => "form form-horizontal" do %>
+ <%= render :partial => 'admin_public_body_change_requests/response'%>
+ <div class="form-actions">
+ <%= submit_tag 'Close', :accesskey => 'c', :class => "btn btn-primary" %>
+ </div>
+<% end %>
diff --git a/app/views/admin_public_body_change_requests/update_accepted.txt.erb b/app/views/admin_public_body_change_requests/update_accepted.txt.erb
new file mode 100644
index 000000000..9c29c959b
--- /dev/null
+++ b/app/views/admin_public_body_change_requests/update_accepted.txt.erb
@@ -0,0 +1,7 @@
+<%= _("Dear {{user_name}},", :user_name => @change_request.get_user_name) %>
+
+<%= _("Thanks for your suggestion to update the email address for {{public_body_name}} to {{public_body_email}}. This has now been done and any new requests will be sent to the new address.", :public_body_name => @change_request.public_body.name, :public_body_email => @change_request.public_body_email) %>
+
+<%= _("Yours,") %>
+
+<%= _("The {{site_name}} team.", :site_name => site_name) %>
diff --git a/app/views/admin_request/_some_annotations.html.erb b/app/views/admin_request/_some_annotations.html.erb
new file mode 100644
index 000000000..dfd46f828
--- /dev/null
+++ b/app/views/admin_request/_some_annotations.html.erb
@@ -0,0 +1,48 @@
+<% 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)%>
+ <% 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 |%>
+ <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>
+ <% end %>
+ </div>
+<% else %>
+ <p>None yet.</p>
+<% end %>
+
diff --git a/app/views/admin_request/show.html.erb b/app/views/admin_request/show.html.erb
index 83d9c3764..2589e52b4 100644
--- a/app/views/admin_request/show.html.erb
+++ b/app/views/admin_request/show.html.erb
@@ -325,53 +325,8 @@
<hr>
<h2>Annotations</h2>
-<% if @info_request.comments.size > 0 %>
- <div class="accordion" id="comments">
- <% for comment in @info_request.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)%>
- <% 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 |%>
- <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>
- <% end %>
- </div>
-<% else %>
- <p>None yet.</p>
-<% end %>
+<%= render :partial => 'admin_request/some_annotations' , :locals => { :comments => @info_request.comments } %>
+
<hr>
<h2>Mail server delivery logs</h2>
diff --git a/app/views/admin_user/show.html.erb b/app/views/admin_user/show.html.erb
index c93c08e50..6d12aeff5 100644
--- a/app/views/admin_user/show.html.erb
+++ b/app/views/admin_user/show.html.erb
@@ -91,6 +91,12 @@
<hr>
+<h2>Annotations</h2>
+
+<%= render :partial => 'admin_request/some_annotations' , :locals => { :comments => @admin_user.comments } %>
+
+<hr>
+
<h2>Censor rules</h2>
<%= render :partial => 'admin_censor_rule/show', :locals => { :censor_rules => @admin_user.censor_rules, :user => @admin_user } %>
diff --git a/app/views/comment/_single_comment.html.erb b/app/views/comment/_single_comment.html.erb
index d2edc8dbe..a6d234b34 100644
--- a/app/views/comment/_single_comment.html.erb
+++ b/app/views/comment/_single_comment.html.erb
@@ -17,10 +17,10 @@
</div>
<p class="event_actions">
<% if !comment.id.nil? %>
- <%= link_to "Link to this", comment_path(comment), :class => "link_to_this" %>
<% if !@user.nil? && @user.admin_page_links? %>
- | <%= link_to "Admin", admin_request_edit_comment_path(comment) %>
+ <%= link_to "Admin", admin_request_edit_comment_path(comment) %> |
<% end %>
+ <%= link_to "Link to this", comment_path(comment), :class => "link_to_this" %>
<!-- | <%= link_to _('Report abuse'), comment_path(comment) %> -->
<% end %>
</p>
diff --git a/app/views/contact_mailer/add_public_body.text.erb b/app/views/contact_mailer/add_public_body.text.erb
new file mode 100644
index 000000000..5baa1fa1a
--- /dev/null
+++ b/app/views/contact_mailer/add_public_body.text.erb
@@ -0,0 +1,19 @@
+<%= _("{{user_name}} would like a new authority added to {{site_name}}", :user_name => @change_request.get_user_name, :site_name => site_name) %>
+
+<%= _("Authority:") %>
+<%= @change_request.get_public_body_name %>
+
+<%= _("Email:") %>
+<%= @change_request.public_body_email %>
+
+<%= _("Source:") %>
+<%= @change_request.source_url %>
+
+<%= _("Notes:") %>
+<%= @change_request.notes %>
+
+<%= _('Add the authority:') %>
+<%= admin_body_new_url(:change_request_id => @change_request.id, :only_path => false ) %>
+
+<%= _('Close the request and respond:') %>
+<%= admin_change_request_edit_url(:id => @change_request.id, :only_path => false ) %>
diff --git a/app/views/contact_mailer/from_admin_message.text.erb b/app/views/contact_mailer/from_admin_message.text.erb
index 4169d8d3a..3af759c5d 100644
--- a/app/views/contact_mailer/from_admin_message.text.erb
+++ b/app/views/contact_mailer/from_admin_message.text.erb
@@ -1,2 +1 @@
<%= raw @message %>
-
diff --git a/app/views/contact_mailer/update_public_body_email.text.erb b/app/views/contact_mailer/update_public_body_email.text.erb
new file mode 100644
index 000000000..7d5a3dae0
--- /dev/null
+++ b/app/views/contact_mailer/update_public_body_email.text.erb
@@ -0,0 +1,16 @@
+<%= _("{{user_name}} would like the email address for {{public_body_name}} to be updated", :user_name => @change_request.get_user_name, :public_body_name => @change_request.get_public_body_name) %>
+
+<%= _("Email:") %>
+<%= @change_request.public_body_email %>
+
+<%= _("Source:") %>
+<%= @change_request.source_url %>
+
+<%= _("Notes:") %>
+<%= @change_request.notes %>
+
+<%= _('Update the address:') %>
+<%= admin_body_edit_path(@change_request.public_body, :change_request_id => @change_request.id, :only_path => false) %>
+
+<%= _('Close the request and respond:') %>
+<%= admin_change_request_edit_url(:id => @change_request.id, :only_path => false ) %>
diff --git a/app/views/general/_footer.html.erb b/app/views/general/_footer.html.erb
index 04c60be3d..2e10a0f94 100644
--- a/app/views/general/_footer.html.erb
+++ b/app/views/general/_footer.html.erb
@@ -1,6 +1,8 @@
<div id="footer">
<%= link_to _("Contact {{site_name}}", :site_name => site_name), help_contact_path %>
+<% unless AlaveteliConfiguration::twitter_username.blank? %>
| <%= image_tag "twitter-16.png", :alt => "twitter icon", :class => "twitter-icon" %> <a href="https://twitter.com/<%= AlaveteliConfiguration::twitter_username %>"><%= _("Follow us on twitter") %></a>
+<% end %>
<%= render :partial => 'general/credits' %>
</div>
<div class="after-footer">&nbsp;</div>
diff --git a/app/views/general/_localised_datepicker.html.erb b/app/views/general/_localised_datepicker.html.erb
index ec6593ea0..ee3206957 100644
--- a/app/views/general/_localised_datepicker.html.erb
+++ b/app/views/general/_localised_datepicker.html.erb
@@ -1,16 +1,16 @@
<script type="text/javascript">
$(function() {
$(".use-datepicker").datepicker(
- {closeText: '<%= _("Done") %>',
- prevText: '<%= _("Prev") %>',
- nextText: '<%= _("Next") %>',
- currentText: '<%= _("Today") %>',
+ {closeText: '<%= j _("Done") %>',
+ prevText: '<%= j _("Prev") %>',
+ nextText: '<%= j _("Next") %>',
+ currentText: '<%= j _("Today") %>',
monthNames: <%= raw I18n.translate('date.month_names')[1..-1].to_json %>,
monthNamesShort: <%= raw I18n.translate('date.abbr_month_names')[1..-1].to_json %>,
dayNames: <%= raw I18n.translate('date.day_names').to_json %>,
dayNamesShort: <%= raw I18n.translate('date.abbr_day_names').to_json %>,
dayNamesMin: <%= raw I18n.translate('date.abbr_day_names').collect{|x| x[0..0]}.to_json %>,
- weekHeader: '<%= _("Wk") %>',
+ weekHeader: '<%= j _("Wk") %>',
dateFormat: '<%= I18n.translate('date.formats.default').sub("%Y", "yy").sub("%m", "mm").sub("%d", "dd").gsub("-", "/") %>'}
);
});
diff --git a/app/views/general/_stylesheet_includes.html.erb b/app/views/general/_stylesheet_includes.html.erb
index b3f32054c..7a1648efd 100644
--- a/app/views/general/_stylesheet_includes.html.erb
+++ b/app/views/general/_stylesheet_includes.html.erb
@@ -17,6 +17,6 @@
<%= stylesheet_link_tag 'ie7.css' %>
<![endif]-->
<% if AlaveteliConfiguration::force_registration_on_new_request %>
- <%= stylesheet_link_tag 'jquery.fancybox-1.3.4.pack.js', :rel => "stylesheet" %>
+ <%= stylesheet_link_tag 'jquery.fancybox-1.3.4.css', :rel => "stylesheet" %>
<% end %>
<% end %>
diff --git a/app/views/general/_topnav.html.erb b/app/views/general/_topnav.html.erb
index c7f2cedea..d37bd97d1 100644
--- a/app/views/general/_topnav.html.erb
+++ b/app/views/general/_topnav.html.erb
@@ -4,7 +4,9 @@
<li class="<%= 'selected' if params[:controller] == 'request' and ['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("Make a request"), select_authority_path, :id => 'make-request-link' %></li>
<li class="<%= 'selected' if params[:controller] == 'request' and !['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("View requests"), request_list_successful_path %></li>
<li class="<%= 'selected' if params[:controller] == 'public_body' %>"><%= link_to _("View authorities"), list_public_bodies_default_path %></li>
+<% unless AlaveteliConfiguration::blog_feed.empty? %>
<li class="<%= 'selected' if params[:controller] == 'general' and params[:action] == 'blog' %>"><%= link_to _("Read blog"), blog_path %></li>
+<% end %>
<li class="<%= 'selected' if params[:controller] == 'help' %>"><%= link_to _("Help"), help_about_path %></li>
</ul>
</div>
diff --git a/app/views/help/api.html.erb b/app/views/help/api.html.erb
index df7bb30b6..c6488f93e 100644
--- a/app/views/help/api.html.erb
+++ b/app/views/help/api.html.erb
@@ -71,7 +71,15 @@
</p>
</dd>
- </dl>
+
+
+ <dt> 5. Write API </dt>
+ <dd>
+ <p>
+ The write API is designed to be used by authorities to create their own requests in the system. The API is currently used by mySociety's <a href="https://github.com/mysociety/foi-register">FOI Register software</a> to support using Alaveteli as a disclosure log for all FOI activity at a particular public body. More technical information about the write API is available on the <a href="https://github.com/mysociety/alaveteli/wiki/API#write-api">Alaveteli wiki</a>.
+ </p>
+ </dd>
+</dl>
<p>Please <a href="<%= help_contact_path %>">contact us</a> if you need an API feature that isn't there yet. It's
very much a work in progress, and we do add things when people ask us to.</p>
diff --git a/app/views/help/privacy.html.erb b/app/views/help/privacy.html.erb
index 8e5293892..8ee7da385 100644
--- a/app/views/help/privacy.html.erb
+++ b/app/views/help/privacy.html.erb
@@ -84,6 +84,11 @@ ask a friend to. We don't have the resources to do this for everyone.
</dd>
+<dt id="anonymous">Why are there anonymous requests on the site? <a href="#anonymous">#</a> </dt>
+<dd>
+Some public authorities are using mySociety's <a href="https://github.com/mysociety/foi-register">FOI Register</a> software in order to use WhatDoTheyKnow as a disclosure log for all their FOI activity. When people make requests to the authority their names will usually be withheld from publication just as they would in an authority disclosure log on an authority website.
+</dd>
+
<dt id="full_address">They've asked for my postal address! <a href="#full_address">#</a> </dt>
<dd>
diff --git a/app/views/help/requesting.html.erb b/app/views/help/requesting.html.erb
index e7cfdd199..9de995435 100644
--- a/app/views/help/requesting.html.erb
+++ b/app/views/help/requesting.html.erb
@@ -30,7 +30,7 @@
<dt id="missing_body">You're missing the public authority that I want to request from! <a href="#missing_body">#</a> </dt>
<dd>
- <p>Please <a href="<%= help_contact_path %>">contact us</a> with the name of the public authority and,
+ <p>Please <a href="<%= new_change_request_path %>">contact us</a> with the name of the public authority and,
if you can find it, their contact email address for Freedom of Information requests.
</p>
<p>If you'd like to help add a whole category of public authority to the site, we'd love
diff --git a/app/views/layouts/_favicon.html.erb b/app/views/layouts/_favicon.html.erb
index 4f3859d6c..0ee7d48e3 100644
--- a/app/views/layouts/_favicon.html.erb
+++ b/app/views/layouts/_favicon.html.erb
@@ -1 +1 @@
-<link rel="shortcut icon" href="/favicon.ico">
+<%= favicon_link_tag 'favicon.ico' %>
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb
index 8d69b2a08..52b718be8 100644
--- a/app/views/layouts/default.html.erb
+++ b/app/views/layouts/default.html.erb
@@ -66,16 +66,22 @@
<% if is_admin? %>
<%= render :partial => 'admin_general/admin_navbar' %>
<% end %>
-<% popup_banner = render(:partial => "general/popup_banner").strip %>
-<% if popup_banner.present? %>
-<div id="everypage" class="jshide">
- <p class="popup-close"><a href="#top" onclick="$.cookie('seen_foi2', 1, { expires: 7, path: '/' }); $('#everypage').hide('slow'); return false;"><%= _('Close') %></a></p>
- <%= raw popup_banner %>
- <p class="popup-close"><a href="#top" onclick="$.cookie('seen_foi2', 1, { expires: 7, path: '/' }); $('#everypage').hide('slow'); return false;"><%= _('Close') %></a></p>
-</div>
-<% end %>
<div class="entirebody">
+ <% popup_banner = render(:partial => "general/popup_banner").strip %>
+ <% if popup_banner.present? and ! @render_to_file %>
+ <div id="everypage" class="popup">
+ <span class="popup-content">
+ <%= raw popup_banner %>
+ </span>
+ <span class="popup-close"><a href="#top" ><%= _('Close') %></a></span>
+ </div>
+ <% end %>
+ <div id="other-country-notice" class="popup">
+ <span class="popup-content">
+ </span>
+ <span class="popup-close"><a href="#top" ><%= _('Close') %></a></span>
+ </div>
<%= render :partial => 'general/header' %>
<div id="wrapper">
<div id="content">
@@ -96,7 +102,6 @@
<%= render :partial => 'general/footer' %>
</div>
-<div id="other-country-notice"></div>
<div id="link_box"><span class="close-button">X</span>
<%= _("Paste this link into emails, tweets, and anywhere else:") %>
<br />
diff --git a/app/views/layouts/no_chrome.html.erb b/app/views/layouts/no_chrome.html.erb
index 589e1bb76..e613b8ca2 100644
--- a/app/views/layouts/no_chrome.html.erb
+++ b/app/views/layouts/no_chrome.html.erb
@@ -14,7 +14,6 @@
<%= stylesheet_link_tag 'application', :title => "Main", :rel => "stylesheet" %>
<%= stylesheet_link_tag 'fonts', :rel => "stylesheet" %>
- <%= stylesheet_link_tag 'theme', :rel => "stylesheet" %>
<!--[if LT IE 7]>
<%= stylesheet_link_tag 'ie6', :rel => "stylesheet" %>
<![endif]-->
diff --git a/app/views/outgoing_mailer/initial_request.text.erb b/app/views/outgoing_mailer/initial_request.text.erb
index 5c418ecc7..b0f1dc9e8 100644
--- a/app/views/outgoing_mailer/initial_request.text.erb
+++ b/app/views/outgoing_mailer/initial_request.text.erb
@@ -6,7 +6,7 @@
<%= @info_request.incoming_email %>
<%= _('Is {{email_address}} the wrong address for {{type_of_request}} requests to {{public_body_name}}? If so, please contact us using this form:', :email_address => @info_request.public_body.request_email, :type_of_request => @info_request.law_used_full, :public_body_name => @info_request.public_body.name)%>
-<%= help_contact_url %>
+<%= new_change_request_url(:body => @info_request.public_body.url_name) %>
<%= render :partial => 'followup_footer' %>
diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb
index b35e29eea..c36396149 100644
--- a/app/views/public_body/show.html.erb
+++ b/app/views/public_body/show.html.erb
@@ -32,6 +32,7 @@
<% end %>
<% end %>
<%= link_to _('View FOI email address'), view_public_body_email_path(@public_body.url_name) %><br>
+ <%= link_to _("Ask us to update FOI email"), new_change_request_path(:body => @public_body.url_name) %><br>
</div>
<div id="header_left">
diff --git a/app/views/public_body_change_requests/new.html.erb b/app/views/public_body_change_requests/new.html.erb
new file mode 100644
index 000000000..7079cd868
--- /dev/null
+++ b/app/views/public_body_change_requests/new.html.erb
@@ -0,0 +1,61 @@
+<h1><%= @title %></h1>
+<%= foi_error_messages_for :change_request %>
+ <%= form_for(@change_request, :url => change_request_path) do |f| %>
+<% if not @user %>
+ <p>
+ <label class="form_label" for="user_name">
+ <%= _("Your name:") %>
+ </label>
+ <%= f.text_field :user_name %>
+ <%= _('(or <a href="{{url}}">sign in</a>)', :url => signin_path(:r => request.fullpath)) %>
+ </p>
+
+ <p>
+ <label class="form_label" for="user_email">
+ <%= ("Your email:") %>
+ </label>
+ <%= f.text_field :user_email %>
+ </p>
+<% end %>
+<% if @change_request.public_body %>
+ <%= f.hidden_field :public_body_id %>
+<% else %>
+ <p>
+ <label class="form_label" for="public_body_name">
+ <%= _("Authority:") %>
+ </label>
+ <%= f.text_field :public_body_name %>
+ </p>
+<% end %>
+ <p>
+ <label class="form_label" for="public_body_email">
+ <%= _("Authority email:") %>
+ </label>
+ <%= f.text_field :public_body_email %>
+ <div class="form_item_note">
+ <%= _("The contact email address for FOI requests to the authority.") %>
+ </div>
+ </p>
+
+ <p>
+ <label class="form_label" for="source_url">
+ <%= _("Source URL:") %>
+ </label>
+ <%= f.text_field :source_url %>
+ <div class="form_item_note">
+ <%= _("The URL where you found the email address. This field is optional, but it would help us a lot if you can provide a link to a specific page on the authority's website that gives this address, as it will make it much easier for us to check.") %>
+ </div>
+ </p>
+
+ <p>
+ <label class="form_label" for="notes">
+ <%= _("Notes:") %>
+ </label>
+ <%= f.text_area :notes, :rows => 10, :cols => 60 %>
+ </p>
+
+ <div class="form_button">
+ <%= submit_tag _("Submit request") %>
+ </div>
+
+<% end %>
diff --git a/app/views/reports/new.html.erb b/app/views/reports/new.html.erb
index 7d558ab4e..1197b2255 100644
--- a/app/views/reports/new.html.erb
+++ b/app/views/reports/new.html.erb
@@ -4,17 +4,17 @@
<p><%= _("This request has already been reported for administrator attention") %></p>
<% else %>
<p>
- Reporting a request notifies the site administrators. They will respond as soon as possible.
+ <%= _("Reporting a request notifies the site administrators. They will respond as soon as possible.") %>
</p>
- <p>Why specifically do you consider this request unsuitable?</p>
+ <p><%= _("Why specifically do you consider this request unsuitable?") %></p>
<%= form_tag request_report_path(:request_id => @info_request.url_title) do %>
<p>
<label class="form_label" for="reason">Reason:</label>
- <%= select_tag :reason, options_for_select(@info_request.report_reasons, @reason), :prompt => "Choose a reason" %>
+ <%= select_tag :reason, options_for_select(@info_request.report_reasons, @reason), :prompt => _("Choose a reason") %>
</p>
<p>
- <label class="form_label" for="message">Please tell us more:</label>
+ <label class="form_label" for="message"><%= _("Please tell us more:") %></label>
<%= text_area_tag :message, @message, :rows => 10, :cols => 60 %>
</p>
diff --git a/app/views/request/_act.html.erb b/app/views/request/_act.html.erb
new file mode 100644
index 000000000..1199cb4a2
--- /dev/null
+++ b/app/views/request/_act.html.erb
@@ -0,0 +1,15 @@
+<h2><%= _("Act on what you've learnt") %></h2>
+
+<div class="act_link">
+ <% tweet_link = "https://twitter.com/share?" + {:url => request.url, :via => AlaveteliConfiguration::twitter_username, :text => "'#{@info_request.title}'", :related => _('alaveteli_foi:The software that runs {{site_name}}', :site_name => site_name)}.to_query %>
+ <% link_to tweet_link do %>
+ <%= image_tag "twitter-16.png", :alt => "twitter icon" %>
+ <% end %>
+ <%= link_to _("Tweet this request"), tweet_link %>
+</div>
+<div class="act_link">
+ <%= link_to "http://wordpress.com/" do %>
+ <%= image_tag "wordpress.png", :class => "rss" %>
+ <% end %>
+ <%= link_to _("Start your own blog"), "http://wordpress.com/"%>
+</div>
diff --git a/app/views/request/_bubble.html.erb b/app/views/request/_bubble.html.erb
index 8827d114d..e038bb3dc 100644
--- a/app/views/request/_bubble.html.erb
+++ b/app/views/request/_bubble.html.erb
@@ -13,7 +13,7 @@
:file_name => a.display_filename + '.html')
%>
<% img_filename = "icon_" + a.content_type.sub('/', '_') + "_large.png"
- full_filename = File.expand_path(File.join(File.dirname(__FILE__), "../../assets/images", img_filename))
+ full_filename = File.expand_path(Rails.root.join('app', 'assets', 'images', img_filename))
if File.exist?(full_filename) %>
<%= link_to image_tag(img_filename, :class => "attachment_image", :alt => "Attachment"), attachment_path %>
<% else %>
diff --git a/app/views/request/_list_results.html.erb b/app/views/request/_list_results.html.erb
new file mode 100644
index 000000000..4da042816
--- /dev/null
+++ b/app/views/request/_list_results.html.erb
@@ -0,0 +1,12 @@
+ <% @results = InfoRequest.request_list(@filters, @page, @per_page, @max_results) %>
+ <% if @results[:results].empty? %>
+ <p> <%= _('No requests of this sort yet.')%></p>
+ <% else %>
+ <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 } %>
+ <% end %>
+ </div>
+ <% end %>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @results[:show_no_more_than]) %>
diff --git a/app/views/request/_sidebar.html.erb b/app/views/request/_sidebar.html.erb
index 8400cd6ac..0f7965ffa 100644
--- a/app/views/request/_sidebar.html.erb
+++ b/app/views/request/_sidebar.html.erb
@@ -33,22 +33,7 @@
<%= link_to _("Report this request"), new_request_report_path(:request_id => @info_request.url_title) %>
<% end %>
<% end %>
- <h2><%= _("Act on what you've learnt") %></h2>
-
- <div class="act_link">
- <% tweet_link = "https://twitter.com/share?" + {:url => request.url, :via => AlaveteliConfiguration::twitter_username, :text => "'#{@info_request.title}'", :related => _('alaveteli_foi:The software that runs {{site_name}}', :site_name => site_name)}.to_query %>
- <% link_to tweet_link do %>
- <%= image_tag "twitter-16.png", :alt => "twitter icon" %>
- <% end %>
- <%= link_to _("Tweet this request"), tweet_link %>
- </div>
- <div class="act_link">
- <%= link_to "http://wordpress.com/" do %>
- <%= image_tag "wordpress.png", :class => "rss" %>
- <% end %>
- <%= link_to _("Start your own blog"), "http://wordpress.com/"%>
- </div>
-
+ <%= render :partial => 'request/act' %>
<%= render :partial => 'request/next_actions' %>
<% cache_if_caching_fragments(@similar_cache_key, :expires_in => 1.day) do %>
diff --git a/app/views/request/_view_html_prefix.html.erb b/app/views/request/_view_html_prefix.html.erb
index 63caa98d4..63fac7c6d 100644
--- a/app/views/request/_view_html_prefix.html.erb
+++ b/app/views/request/_view_html_prefix.html.erb
@@ -1,9 +1,9 @@
<div class="view_html_prefix">
<div class="view_html_logo">
- <a href="/"><%= image_tag "navimg/logo-trans-small.png", :alt => site_name %></a>
+ <a href="/"><img src="/assets/navimg/logo-trans-small.png" alt="<%= site_name %>"></a>
</div>
<div class="view_html_download_link">
- <%=link_to _("Download original attachment"), @attachment_url %>
+ <%=link_to _("Download original attachment"), @attachment_url %>
<br>(<%=h @attachment.name_of_content_type %>)
</div>
<%= _('This is an HTML version of an attachment to the Freedom of Information request')%>
diff --git a/app/views/request/_view_html_stylesheet.html.erb b/app/views/request/_view_html_stylesheet.html.erb
index d6cb932a8..125ce66ec 100644
--- a/app/views/request/_view_html_stylesheet.html.erb
+++ b/app/views/request/_view_html_stylesheet.html.erb
@@ -1 +1 @@
-<%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %>
+<link type="text/css" title="Main" rel="stylesheet" media="screen" href="/assets/application.css">
diff --git a/app/views/request/list.html.erb b/app/views/request/list.html.erb
index 062b77c3e..a465f03ba 100644
--- a/app/views/request/list.html.erb
+++ b/app/views/request/list.html.erb
@@ -14,21 +14,11 @@
<div style="clear:both"></div>
<div class="results_section">
- <% # TODO: Cache for 5 minutes %>
- <% if @list_results.empty? %>
- <p> <%= _('No requests of this sort yet.')%></p>
- <% else %>
- <h2 class="foi_results"><%= _('{{count}} FOI requests found', :count => @matches_estimated) %></h2>
- <div class="results_block">
- <% for result in @list_results%>
- <% if result.class.to_s == 'InfoRequestEvent' %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result, :info_request => result.info_request } %>
- <% else %>
- <p><strong><%= _('Unexpected search result type') %> <%=result.class.to_s%></strong></p>
- <% end %>
- <% end %>
- </div>
+ <% if key = request_list_cache_key %>
+ <% cache_if_caching_fragments(key, :expires_in => 5.minutes) do %>
+ <%= render :partial => 'list_results' %>
<% end %>
-
- <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @show_no_more_than) %>
+ <% else %>
+ <%= render :partial => 'list_results' %>
+ <% end %>
</div>
diff --git a/app/views/request/show.html.erb b/app/views/request/show.html.erb
index c520ce40c..153b0b861 100644
--- a/app/views/request/show.html.erb
+++ b/app/views/request/show.html.erb
@@ -34,14 +34,16 @@
<p class="subtitle">
<% if !@user.nil? && @user.admin_page_links? %>
<%= _('{{user}} ({{user_admin_link}}) made this {{law_used_full}} request (<a href="{{request_admin_url}}">admin</a>) to {{public_body_link}} (<a href="{{public_body_admin_url}}">admin</a>)',
- :user => @info_request.is_external? ? (@info_request.user_name || _('An anonymous user')) : user_link(@info_request.user),
+ :user => request_user_link(@info_request, _('An anonymous user')),
:law_used_full => h(@info_request.law_used_full),
:user_admin_link => user_admin_link_for_request(@info_request, _('external'), _('admin')),
:request_admin_url => admin_request_show_url(@info_request),
:public_body_link => public_body_link(@info_request.public_body),
:public_body_admin_url => admin_body_show_url(@info_request.public_body)) %>
<% else %>
- <%= _('{{user}} made this {{law_used_full}} request',:user=>@info_request.is_external? ? (@info_request.user_name || _('An anonymous user')) : user_link(@info_request.user), :law_used_full=>h(@info_request.law_used_full)) %>
+ <%= _('{{user}} made this {{law_used_full}} request',
+ :user=>request_user_link(@info_request, _('An anonymous user')),
+ :law_used_full=>h(@info_request.law_used_full)) %>
<%= _('to {{public_body}}',:public_body=>public_body_link(@info_request.public_body)) %>
<% end %>
</p>
diff --git a/app/views/user/sign.html.erb b/app/views/user/sign.html.erb
index 8291cdace..e8c5d5a58 100644
--- a/app/views/user/sign.html.erb
+++ b/app/views/user/sign.html.erb
@@ -13,7 +13,7 @@
</p>
<% if @post_redirect.post_params["controller"] == "admin_general" %>
<% unless AlaveteliConfiguration::disable_emergency_user %>
- <p id="superuser_message">Don't have a superuser account yet? <%= link_to "Sign in as the emergency user", @post_redirect.uri + "?emergency=1" %></p>
+ <p id="superuser_message"><%= _("Don't have a superuser account yet?") %> <%= link_to _("Sign in as the emergency user"), @post_redirect.uri + "?emergency=1" %></p>
<% end %>
<% end %>
diff --git a/app/views/user/wall.html.erb b/app/views/user/wall.html.erb
index 190cc0a6d..6699c55fa 100644
--- a/app/views/user/wall.html.erb
+++ b/app/views/user/wall.html.erb
@@ -1,16 +1,19 @@
<% @title = h(@display_user.name) + _(" - wall") %>
-<% if @is_you %>
<div class="medium_column">
- <p><%= _('You can change the requests and users you are following on <a href="{{profile_url}}">your profile page</a>.', :profile_url => show_user_profile_path) %>
- <%= render :partial => 'change_receive_email' %>
+ <% if @is_you %>
+ <h2><%= _("My wall") %></h2>
+ <p><%= _('You can change the requests and users you are following on <a href="{{profile_url}}">your profile page</a>.', :profile_url => show_user_profile_path) %></p>
+ <%= render :partial => 'change_receive_email' %>
+ <% else %>
+ <h2><%= _("This is <a href=\"{{profile_url}}\">{{user_name}}'s</a> wall", :profile_url => show_user_profile_path, :user_name => h(@display_user.name)) %></h2>
+ <% end %>
</div>
-<% end %>
<div id="user_profile_search">
- <% if !@feed_results.nil? %>
- <% for result in @feed_results %>
- <%= render :partial => 'request/wall_listing', :locals => { :event => result, :info_request => result.info_request } %>
- <% end %>
- <% end %>
-
-
+ <% if !@feed_results.nil? and !@feed_results.empty? %>
+ <% for result in @feed_results %>
+ <%= render :partial => 'request/wall_listing', :locals => { :event => result, :info_request => result.info_request } %>
+ <% end %>
+ <% else %>
+ <p><%= _("There is nothing to display yet.") %></p>
+ <% end %>
</div>