aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cabo <david@calibea.com>2011-08-17 11:05:21 +0200
committerDavid Cabo <david@calibea.com>2011-08-17 11:05:21 +0200
commit817ce18d16d037aadc5ea44d93854c6e17f06747 (patch)
tree1820f4a62c1060063e0b9751473eca9610142598
parent0ca78b7c2abfe28ef7acd7137fda5d82a973c2e1 (diff)
parente1a2e1ad36c6b0c7bfac501eb2a0d0ae5efd05a1 (diff)
Merge branch 'fixes' into asktheeu
-rw-r--r--.gitignore3
-rw-r--r--app/controllers/admin_public_body_controller.rb26
-rw-r--r--app/controllers/request_controller.rb2
-rwxr-xr-xapp/helpers/link_to_helper.rb2
-rw-r--r--app/models/incoming_message.rb5
-rw-r--r--app/models/info_request.rb2
-rw-r--r--app/models/outgoing_message.rb5
-rw-r--r--app/models/public_body.rb73
-rw-r--r--app/views/admin_public_body/_form.rhtml57
-rw-r--r--app/views/admin_public_body/edit.rhtml6
-rw-r--r--app/views/admin_public_body/new.rhtml6
-rw-r--r--app/views/admin_public_body/show.rhtml11
-rw-r--r--app/views/general/_frontpage_intro_sentence.rhtml3
-rw-r--r--app/views/general/blog.rhtml7
-rw-r--r--app/views/general/frontpage.rhtml4
-rw-r--r--app/views/help/_why_they_should_reply_by_email.rhtml3
-rw-r--r--app/views/help/about.rhtml10
-rw-r--r--app/views/help/api.rhtml6
-rw-r--r--app/views/help/contact.rhtml2
-rw-r--r--app/views/help/credits.rhtml4
-rw-r--r--app/views/help/officers.rhtml30
-rw-r--r--app/views/help/privacy.rhtml4
-rw-r--r--app/views/help/requesting.rhtml20
-rw-r--r--app/views/help/unhappy.rhtml6
-rw-r--r--app/views/request/_view_html_prefix.rhtml2
-rw-r--r--app/views/request/new_bad_contact.rhtml4
-rw-r--r--app/views/request/show_response.rhtml4
-rw-r--r--app/views/user/set_profile_about_me.rhtml2
-rw-r--r--app/views/user/show.rhtml2
-rw-r--r--config/environment.rb1
-rw-r--r--config/general.yml-example3
-rw-r--r--lib/rack_quote_monkeypatch.rb65
-rwxr-xr-xscript/compact-xapian-database29
-rw-r--r--spec/controllers/admin_public_body_controller_spec.rb90
-rw-r--r--spec/controllers/general_controller_spec.rb1
-rw-r--r--spec/controllers/request_controller_spec.rb9
-rw-r--r--spec/integration/search_request_spec.rb9
-rw-r--r--spec/lib/i18n_interpolation.rb15
-rw-r--r--spec/models/incoming_message_spec.rb14
-rw-r--r--spec/models/outgoing_message_spec.rb7
-rw-r--r--spec/models/public_body_spec.rb14
41 files changed, 418 insertions, 150 deletions
diff --git a/.gitignore b/.gitignore
index e8317395f..cef86879d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,10 +8,11 @@
*~
._*
.DS_Store
+.autotest
/db/test_structure.sql
moo.txt
*#*#
TAGS
/vendor/plugins/*theme
/locale/model_attributes.rb
-/files/ \ No newline at end of file
+/files/
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index 021122734..60cb324a1 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -82,16 +82,12 @@ class AdminPublicBodyController < AdminController
end
def new
- @locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
- @public_body = PublicBody.new
- render
- end
+ @public_body = PublicBody.new
+ render
end
-
+
def create
- @locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ PublicBody.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_http_auth_user()
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
@@ -104,17 +100,13 @@ class AdminPublicBodyController < AdminController
end
def edit
- @locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
- @public_body = PublicBody.find(params[:id])
- @public_body.last_edit_comment = ""
- render
- end
+ @public_body = PublicBody.find(params[:id])
+ @public_body.last_edit_comment = ""
+ render
end
def update
- @locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ PublicBody.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_http_auth_user()
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
@@ -157,7 +149,7 @@ class AdminPublicBodyController < AdminController
# Try with dry run first
csv_contents = params[:csv_file].read
- en = PublicBody.import_csv(csv_contents, params[:tag], true, admin_http_auth_user(), I18n.available_locales)
+ en = PublicBody.import_csv(csv_contents, params[:tag], true, admin_http_auth_user(), available_locales)
errors = en[0]
notes = en[1]
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index fac57c7e0..dadbb0cbd 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -397,7 +397,7 @@ class RequestController < ApplicationController
flash[:notice] = _("<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))
redirect_to request_url(@info_request)
elsif @info_request.calculate_status == 'waiting_response_very_overdue'
- flash[:notice] = _("<p>Thank you! Your request is long overdue, by more than 40 working days. Most requests should be answered within 20 working days. You might like to complain about this, see below.</p>")
+ flash[:notice] = _("<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 => MySociety::Config.get('REPLY_VERY_LATE_AFTER_DAYS', 40), :late_number_of_days => MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20))
redirect_to unhappy_url(@info_request)
elsif @info_request.calculate_status == 'not_held'
flash[:notice] = _("<p>Thank you! Here are some ideas on what to do next:</p>
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 444129052..558479c26 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -61,7 +61,7 @@ module LinkToHelper
# Public bodies
def public_body_url(public_body)
- return show_public_body_url(:url_name => public_body.url_name, :only_path => true)
+ public_body.url_name.nil? ? '' : show_public_body_url(:url_name => public_body.url_name, :only_path => true)
end
def public_body_link_short(public_body)
link_to h(public_body.short_or_long_name), public_body_url(public_body)
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index ae7d1201e..b0b02fdda 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -569,7 +569,8 @@ class IncomingMessage < ActiveRecord::Base
text.gsub!(/(Complaints and Corporate Affairs Officer)\s+Westminster Primary Care Trust.+/ms, "\\1")
# Remove WhatDoTheyKnow signup links
- text.gsub!(/http:\/\/www.whatdotheyknow.com\/c\/[^\s]+/, "[WDTK login link]")
+ domain = MySociety::Config.get('DOMAIN')
+ text.gsub!(/http:\/\/#{domain}\/c\/[^\s]+/, "[WDTK login link]")
# Remove Home Office survey links
# e.g. http://www.whatdotheyknow.com/request/serious_crime_act_2007_section_7#incoming-12650
@@ -1134,7 +1135,7 @@ class IncomingMessage < ActiveRecord::Base
elsif content_type == 'text/html'
# lynx wordwraps links in its output, which then don't get formatted properly
# by Alaveteli. We use elinks instead, which doesn't do that.
- external_command("/usr/bin/elinks", "-dump-charset", "utf-8", "-force-html", "-dump",
+ external_command("/usr/bin/elinks", "-eval", "'set document.codepage.assume = \"utf-8\"'", "-dump-charset", "utf-8", "-force-html", "-dump",
tempfile.path, :append_to => text)
elsif content_type == 'application/vnd.ms-excel'
# Bit crazy using /usr/bin/strings - but xls2csv, xlhtml and
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 419546c99..c667e1499 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -651,6 +651,8 @@ public
# days is a very long time.
def date_very_overdue_after
last_sent = last_event_forming_initial_request
+ very_late_days_later = MySociety::Config.get('REPLY_VERY_LATE_AFTER_DAYS', 40)
+ school_very_late_days_later = MySociety::Config.get('SPECIAL_REPLY_VERY_LATE_AFTER_DAYS', 60)
if self.public_body.is_school?
# schools have 60 working days maximum (even over a long holiday)
return Holiday.due_date_from(self.date_initial_request_last_sent_at, 60)
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index c7ba362e0..b7e310b1e 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -54,14 +54,15 @@ class OutgoingMessage < ActiveRecord::Base
# How the default letter starts and ends
def get_salutation
- ret = _("Dear ")
+ ret = ""
if self.message_type == 'followup' && !self.incoming_message_followup.nil? && !self.incoming_message_followup.safe_mail_from.nil? && self.incoming_message_followup.valid_to_reply_to?
ret = ret + OutgoingMailer.name_for_followup(self.info_request, self.incoming_message_followup)
else
ret = ret + self.info_request.public_body.name
end
- return ret + ","
+ salutation = _("Dear {{public_body_name}},", :public_body_name => ret)
end
+
def get_signoff
if self.message_type == 'followup' && !self.incoming_message_followup.nil? && !self.incoming_message_followup.safe_mail_from.nil? && self.incoming_message_followup.valid_to_reply_to?
return _("Yours sincerely,")
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index ef1d60e26..e90050688 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -38,7 +38,7 @@ class PublicBody < ActiveRecord::Base
validates_uniqueness_of :short_name, :message => N_("Short name is already taken"), :if => Proc.new { |pb| pb.short_name != "" }
validates_uniqueness_of :name, :message => N_("Name is already taken")
-
+
has_many :info_requests, :order => 'created_at desc'
has_many :track_things, :order => 'created_at desc'
@@ -46,6 +46,40 @@ class PublicBody < ActiveRecord::Base
translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme
+ # Convenience methods for creating/editing translations via forms
+ def translation(locale)
+ self.translations.find_by_locale(locale)
+ end
+
+ # XXX - Don't like repeating this!
+ def calculate_cached_fields(t)
+ t.first_letter = t.name.scan(/^./mu)[0].upcase
+ short_long_name = t.name
+ short_long_name = t.short_name if t.short_name and !t.short_name.empty?
+ t.url_name = MySociety::Format.simplify_url_part(short_long_name, 'body')
+ end
+
+ def translated_versions
+ translations
+ end
+
+ def translated_versions=(translation_attrs)
+ if translation_attrs.respond_to? :each_value # Hash => updating
+ translation_attrs.each_value do |attrs|
+ t = translation(attrs[:locale]) || PublicBody::Translation.new
+ t.attributes = attrs
+ calculate_cached_fields(t)
+ t.save!
+ end
+ else # Array => creating
+ translation_attrs.each do |attrs|
+ new_translation = PublicBody::Translation.new(attrs)
+ calculate_cached_fields(new_translation)
+ translations << new_translation
+ end
+ end
+ end
+
# Make sure publication_scheme gets the correct default value.
# (This would work automatically, were publication_scheme not a translated attribute)
def after_initialize
@@ -54,15 +88,16 @@ class PublicBody < ActiveRecord::Base
# like find_by_url_name but also search historic url_name if none found
def self.find_by_url_name_with_historic(name)
- @locale = I18n.locale.to_s
- PublicBody.with_locale(@locale) do
+ locale = self.locale || I18n.locale
+ PublicBody.with_locale(locale) do
found = PublicBody.find(:all,
:conditions => ["public_body_translations.url_name='#{name}'"],
:joins => :translations,
:readonly => false)
- return found.first if found.size == 1
- # Shouldn't we just make url_name unique?
- raise "Two bodies with the same URL name: #{name}" if found.size > 1
+ # If many bodies are found (usually because the url_name is the same across
+ # locales) return any of them
+ return found.first if found.size >= 1
+
# If none found, then search the history of short names
old = PublicBody::Version.find_all_by_url_name(name)
# Find unique public bodies in it
@@ -138,7 +173,7 @@ class PublicBody < ActiveRecord::Base
return 'defunct'
elsif self.not_apply?
return 'not_apply'
- elsif self.request_email.empty? or self.request_email == 'blank'
+ elsif self.request_email.nil? or self.request_email.empty? or self.request_email == 'blank'
return 'bad_contact'
else
raise "requestable_failure_reason called with type that has no reason"
@@ -190,7 +225,6 @@ class PublicBody < ActiveRecord::Base
# When name or short name is changed, also change the url name
def short_name=(short_name)
-
globalize.write(self.class.locale || I18n.locale, :short_name, short_name)
self[:short_name] = short_name
self.update_url_name
@@ -203,15 +237,15 @@ class PublicBody < ActiveRecord::Base
end
def update_url_name
- url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body')
- self.url_name = url_name
+ self.url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body')
end
+
# Return the short name if present, or else long name
def short_or_long_name
- if self.short_name.nil? # can happen during construction
+ if self.short_name.nil? || self.short_name.empty? # 'nil' can happen during construction
self.name
else
- self.short_name.empty? ? self.name : self.short_name
+ self.short_name
end
end
@@ -340,9 +374,12 @@ class PublicBody < ActiveRecord::Base
row.each_with_index {|field, i| field_names[field] = i}
next
end
+
+ fields = {}
+ field_names.each{|name, i| fields[name] = row[i]}
- name = row[field_names['name']]
- email = row[field_names['email']]
+ name = fields['name']
+ email = fields['email']
next if name.nil?
if email.nil?
email = '' # unknown/bad contact is empty string
@@ -355,7 +392,7 @@ class PublicBody < ActiveRecord::Base
errors.push "error: line " + line.to_s + ": invalid email " + email + " for authority '" + name + "'"
next
end
-
+
if bodies_by_name[name]
# Already have the public body, just update email
public_body = bodies_by_name[name]
@@ -366,9 +403,9 @@ class PublicBody < ActiveRecord::Base
public_body.last_edit_comment = 'Updated from spreadsheet'
public_body.save!
end
-
+
additional_locales.each do |locale|
- localized_name = field_names["name.#{locale}"] && row[field_names["name.#{locale}"]]
+ localized_name = fields["name.#{locale}"]
PublicBody.with_locale(locale) do
if !localized_name.nil? and public_body.name != localized_name
notes.push "line " + line.to_s + ": updating name for '#{name}' from '#{public_body.name}' to '#{localized_name}' (locale: #{locale})."
@@ -385,7 +422,7 @@ class PublicBody < ActiveRecord::Base
public_body.save!
additional_locales.each do |locale|
- localized_name = field_names["name.#{locale}"] && row[field_names["name.#{locale}"]]
+ localized_name = fields["name.#{locale}"]
if !localized_name.nil?
PublicBody.with_locale(locale) do
notes.push "line " + line.to_s + ": (aka '#{localized_name}' in locale #{locale})"
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
index b1516be2e..98749154c 100644
--- a/app/views/admin_public_body/_form.rhtml
+++ b/app/views/admin_public_body/_form.rhtml
@@ -21,29 +21,56 @@
<% end %>
</div>
-<p><label for="public_body_name">Name</label><br/>
-<%= text_field 'public_body', 'name', :size => 60 %></p>
+<h3>Localized Fields</h3>
-<p><label for="public_body_short_name">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/>
-<%= text_field 'public_body', 'short_name', :size => 60 %></p>
+<%
+ for locale in I18n.available_locales do
+ if locale==I18n.default_locale # The default locale is submitted as part of the bigger object...
+ prefix = 'public_body'
+ object = @public_body
+ else # ...but additional locales go "on the side"
+ prefix = "public_body[translated_versions][]"
+ object = @public_body.new_record? ?
+ PublicBody::Translation.new :
+ @public_body.translation(locale.to_s) || PublicBody::Translation.new
+ end
-<p><label for="public_body_request_email">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/>
-<%= text_field 'public_body', 'request_email', :size => 40 %></p>
+ fields_for prefix, object do |t|
+%>
+<div>
+ <p>Locale: <%= locale_name(locale.to_s) %></p>
+ <%= t.hidden_field :locale, :value => locale.to_s %>
+
+ <p><label for="public_body_name">Name</label><br/>
+ <%= t.text_field :name, :size => 60 %></p>
-<p><label for="public_body_tag_string">Tags <small>(space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity)</small></label><br/>
-<%= text_field 'public_body', 'tag_string', :size => 60 %></p>
+ <p><label for="public_body_short_name">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/>
+ <%= t.text_field :short_name, :size => 60 %></p>
-<p><label for="public_body_home_page">Home page <small>(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</small></label><br/>
-<%= text_field 'public_body', 'home_page', :size => 60 %></p>
+ <p><label for="public_body_request_email">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/>
+ <%= t.text_field :request_email, :size => 40 %></p>
+
+ <p><label for="public_body_publication_scheme">Publication scheme URL</label><br/>
+ <%= t.text_field :publication_scheme, :size => 60 %></p>
+
+ <p><label for="public_body_notes">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/>
+ <%= t.text_area :notes, :rows => 3, :cols => 60 %></p>
+</div>
+<%
+ end
+ end
+%>
+
+<h3>Common Fields</h3>
-<p><label for="public_body_publication_scheme">Publication scheme URL</label><br/>
-<%= text_field 'public_body', 'publication_scheme', :size => 60 %></p>
+<p><label for="public_body_tag_string">Tags <small>(space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity)</small></label><br/>
+<%= f.text_field :tag_string, :size => 60 %></p>
-<p><label for="public_body_notes">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/>
-<%= text_area 'public_body', 'notes', :rows => 3, :cols => 60 %></p>
+<p><label for="public_body_home_page">Home page <small>(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</small></label><br/>
+<%= f.text_field :home_page, :size => 60 %></p>
<p><label for="public_body_last_edit_comment"><strong>Comment</strong> for this edit</label> <small>(put URL or other source of new info)</small><br/>
-<%= text_area 'public_body', 'last_edit_comment', :rows => 3, :cols => 60 %></p>
+<%= f.text_area :last_edit_comment, :rows => 3, :cols => 60 %></p>
<!--[eoform:public_body]-->
diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml
index 005ec93ce..ae4066dc7 100644
--- a/app/views/admin_public_body/edit.rhtml
+++ b/app/views/admin_public_body/edit.rhtml
@@ -2,9 +2,9 @@
<h1><%=@title%></h1>
-<% form_tag '../update/' + @public_body.id.to_s do %>
- <%= render :partial => 'form' %>
- <p><%= submit_tag 'Save', :accesskey => 's' %></p>
+<% form_for @public_body, :url => {:action => 'update'} do |f| %>
+ <%= render :partial => 'form', :locals => {:f => f} %>
+ <p><%= f.submit 'Save', :accesskey => 's' %></p>
<% end %>
<p>
diff --git a/app/views/admin_public_body/new.rhtml b/app/views/admin_public_body/new.rhtml
index 95208b5b3..fe0b5b670 100644
--- a/app/views/admin_public_body/new.rhtml
+++ b/app/views/admin_public_body/new.rhtml
@@ -2,9 +2,9 @@
<h1><%=@title%></h1>
-<% form_tag 'create' do %>
- <%= render :partial => 'form' %>
- <p><%= submit_tag "Create" %></p>
+<% form_for :public_body, @public_body, :url => {:action => "create"} do |f| %>
+ <%= render :partial => 'form', :locals => {:f => f} %>
+ <p><%= f.submit "Create" %></p>
<% end %>
<p>
diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml
index c1292c63a..643ccf5e8 100644
--- a/app/views/admin_public_body/show.rhtml
+++ b/app/views/admin_public_body/show.rhtml
@@ -12,7 +12,7 @@
<% if column.name == 'home_page' and !column.name.empty? %>
<%= link_to(h(@public_body.send(column.name)), @public_body.send(column.name)) %>
<% elsif column.name == 'request_email' and !column.name.empty? %>
- <%= link_to(h(@public_body.send(column.name)), "mailto:" + @public_body.send(column.name)) %>
+ <%= link_to(h(@public_body.send(column.name)), "mailto:#{@public_body.send(column.name)}") %>
<% if !@public_body.is_requestable? %>
(not requestable due to: <%=h @public_body.not_requestable_reason %><% if @public_body.is_followupable? %>; but followupable<% end %>)
<% end %>
@@ -32,7 +32,14 @@
</p>
<p>
- <%= link_to 'Public page', main_url(public_body_url(@public_body)) %>
+ <%=
+ # url_name can be missing if the name hasn't been set for this locale
+ if !@public_body.url_name.nil?
+ link_to 'Public page', main_url(public_body_url(@public_body))
+ else
+ 'Public page not available'
+ end
+ %>
| <%= link_to 'Edit', '../edit/' + @public_body.id.to_s %>
</p>
diff --git a/app/views/general/_frontpage_intro_sentence.rhtml b/app/views/general/_frontpage_intro_sentence.rhtml
new file mode 100644
index 000000000..2c3bcaf83
--- /dev/null
+++ b/app/views/general/_frontpage_intro_sentence.rhtml
@@ -0,0 +1,3 @@
+First, type in the <strong>name of the UK public authority</strong> you'd
+<br>like information from. <strong>By law, they have to respond</strong>
+(<a href="<%= help_about_url %>">why?</a>).
diff --git a/app/views/general/blog.rhtml b/app/views/general/blog.rhtml
index cbd37240e..c9387c24f 100644
--- a/app/views/general/blog.rhtml
+++ b/app/views/general/blog.rhtml
@@ -1,8 +1,8 @@
<% @title = "#{site_name} blog and tweets" %>
<h1><%=@title %></h1>
- <img src="/images/twitter.png" alt="twitter icon" valign="middle"> <a href="http://www.twitter.com/whatdotheyknow">Follow us on twitter</a>&nbsp;
- <img src="/images/rss.png" alt="RSS icon" valign="middle"> <a href="http://www.mysociety.org/category/projects/whatdotheyknow/feed/">Subscribe to blog</a>
+ <img src="/images/twitter.png" alt="twitter icon" valign="middle"> <a href="http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>">Follow us on twitter</a>&nbsp;
+ <img src="/images/rss.png" alt="RSS icon" valign="middle"> <a href="<%= MySociety::Config.get('BLOG_FEED') %>">Subscribe to blog</a>
<% if !@twitter_user.empty? %>
<div id="twitter">
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
@@ -52,8 +52,5 @@ new TWTR.Widget({
</p>
</div>
<% end %>
- <p>
- <a href="http://www.mysociety.org/category/projects/whatdotheyknow/">All blog posts</a>
- </p>
</div>
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml
index e8e5d8634..abed0294e 100644
--- a/app/views/general/frontpage.rhtml
+++ b/app/views/general/frontpage.rhtml
@@ -5,9 +5,7 @@
<% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
<p>
- <%= _('First, type in the <strong>name of the UK public authority</strong> you\'d
- <br>like information from. <strong>By law, they have to respond</strong>
- (<a href="%s">why?</a>).') % help_about_url %>
+ <%= render :partial => 'frontpage_intro_sentence' %>
<br>
<br>
diff --git a/app/views/help/_why_they_should_reply_by_email.rhtml b/app/views/help/_why_they_should_reply_by_email.rhtml
new file mode 100644
index 000000000..faaa2b2e2
--- /dev/null
+++ b/app/views/help/_why_they_should_reply_by_email.rhtml
@@ -0,0 +1,3 @@
+The law, the Ministry of Justice and the Information Commissioner all say that an email is sufficient (<a href="<%= help_page_url %>#full_address">more details</a>).
+
+At the bottom of this page, write a reply to the authority explaining this to them.
diff --git a/app/views/help/about.rhtml b/app/views/help/about.rhtml
index 89a67d069..d22cc5b30 100644
--- a/app/views/help/about.rhtml
+++ b/app/views/help/about.rhtml
@@ -2,10 +2,10 @@
<%= render :partial => 'sidebar' %>
-<h1 id="introduction">Introduction to WhatDoTheyKnow <a href="#introduction">#</a> </h1>
+<h1 id="introduction">Introduction to <%= site_name %><a href="#introduction">#</a> </h1>
<dl>
-<dt id="purpose">What is WhatDoTheyKnow for? <a href="#purpose">#</a> </dt>
+<dt id="purpose">What is <%= site_name %> for? <a href="#purpose">#</a> </dt>
<dd>To help you find out inside information about what the UK government
is doing.
</dd>
@@ -31,15 +31,15 @@ will either contain the information you want, or give a valid legal reason why
it must be kept confidential.
</dd>
-<dt id="who">Who makes WhatDoTheyKnow? <a href="#who">#</a> </dt>
-<dd>WhatDoTheyKnow is created and run by <a href="http://www.mysociety.org">mySociety</a>,
+<dt id="who">Who makes <%= site_name %>? <a href="#who">#</a> </dt>
+<dd><%= site_name %> is created and run by <a href="http://www.mysociety.org">mySociety</a>,
and was initially <a href="http://www.mysociety.org/2006/12/06/funding-for-freedom-of-information/">funded by the JRSST Charitable Trust</a>. mySociety is a project of the
registered charity <a href="http://www.ukcod.org.uk/UK_Citizens_Online_Democracy">UK Citizens Online Democracy</a>.
If you like what we're doing, then you can
<a href="https://secure.mysociety.org/donate/">make a donation</a>.
</dd>
-<dt id="updates">How can I keep up with news about WhatDoTheyKnow?<a href="#updates">#</a> </dt>
+<dt id="updates">How can I keep up with news about <%= site_name %>?<a href="#updates">#</a> </dt>
<dd>We have a <a href="/blog">blog</a> and a <a href="http://www.twitter.com/whatdotheyknow">twitter feed</a>.
</dd>
diff --git a/app/views/help/api.rhtml b/app/views/help/api.rhtml
index 6f27cf908..3cafbb665 100644
--- a/app/views/help/api.rhtml
+++ b/app/views/help/api.rhtml
@@ -7,10 +7,10 @@
<h2> Introduction </h2>
<p>This page explains how programmers can make other websites and software
-interact with WhatDoTheyKnow via an "API".
+interact with <%= site_name %> via an "API".
</p>
-<p>WhatDoTheyKnow does not have a full API yet, but we are gradually adding
+<p><%= site_name %> does not have a full API yet, but we are gradually adding
lots of things that are similar in use to an API as they are requested.
</p>
@@ -68,7 +68,7 @@ information about the list of events in the feed.
<h2> 4. Spreadsheet of all authorities </h2>
<p>
-A spreadsheet file listing every body in WhatDoTheyKnow is available:
+A spreadsheet file listing every body in <%= site_name %> is available:
<%= link_to "all-authorities.csv", all_public_bodies_csv_url() %>
</p>
diff --git a/app/views/help/contact.rhtml b/app/views/help/contact.rhtml
index 9dd4d4106..6c65fb1c9 100644
--- a/app/views/help/contact.rhtml
+++ b/app/views/help/contact.rhtml
@@ -28,7 +28,7 @@
<% end %>
- <h1>Contact the WhatDoTheyKnow team</h1>
+ <h1>Contact the <%= site_name %> team</h1>
<% if !flash[:notice] %>
<ul>
<li>
diff --git a/app/views/help/credits.rhtml b/app/views/help/credits.rhtml
index ce7b5f123..02cd55c90 100644
--- a/app/views/help/credits.rhtml
+++ b/app/views/help/credits.rhtml
@@ -6,7 +6,7 @@
<dl>
-<dt id="thanks">Which people made WhatDoTheyKnow? <a href="#thanks">#</a> </dt>
+<dt id="thanks">Which people made <%= site_name %>? <a href="#thanks">#</a> </dt>
<dd>Oh, nearly everyone (and <a href="http://www.mysociety.org/helpus">maybe you too</a>)!
<ul>
<li>
@@ -76,7 +76,7 @@ You're all stars.
<li>Help people find successful requests, and monitor performance of authorities, by
<a href="/categorise/play">playing the categorisation game</a>. </li>
<li>Find out FOI email addresses of <a href="/help/requesting#missing_body">authorities that we're missing</a>.</li>
- <li>Write a blog post about either WhatDoTheyKnow or an interesting request that you've
+ <li>Write a blog post about either <%= site_name %> or an interesting request that you've
found. Post about it on a forum that you frequent. Tell friends about it.</li> <li>If you're
a programmer, get the source code for our parent project, <a href="http://alaveteli.org">Alaveteli</a>
and tell us about patches we can pull. It's made in Ruby on Rails.
diff --git a/app/views/help/officers.rhtml b/app/views/help/officers.rhtml
index 3b20ca31a..d9656186a 100644
--- a/app/views/help/officers.rhtml
+++ b/app/views/help/officers.rhtml
@@ -8,17 +8,17 @@
<dt id="top">I just got here from bottom of an FOI request, what is going on? <a href="#top">#</a> </dt>
-<dd><p>WhatDoTheyKnow is a service run by a charity. It helps ordinary members
+<dd><p><%= site_name %> is a service run by a charity. It helps ordinary members
of the public make FOI requests, and easily track and share the responses.</p>
-<p>The FOI request you received was made by someone using WhatDoTheyKnow. You can
+<p>The FOI request you received was made by someone using <%= site_name %>. You can
simply reply to the request as you would any other request from an individual.
The only difference is that your response will be automatically published on
the Internet.
</p>
<p>If you have privacy or other concerns, please read the answers below.
You might also like to read the <a
-href="/help/about">introduction to WhatDoTheyKnow</a> to find out more about what
+href="/help/about">introduction to <%= site_name %></a> to find out more about what
the site does from the point of view of a user. You can also search the
site to find the authority that you work for, and view the status of
any requests made using the site.
@@ -52,23 +52,23 @@ find a page listing all requests that each person has made.
<dd>Yes it is. This
<a href="http://www.whatdotheyknow.com/request/1142/response/2894/attach/5/20080806100741260.pdf">letter from the ICO to Rother District Council</a> gives guidance on the matter, specifically
-in the context of requests made via WhatDoTheyKnow.
+in the context of requests made via <%= site_name %>.
</dd>
<dt id="vexatious">Aren't you making lots of vexatious requests? <a href="#vexatious">#</a> </dt>
-<dd><p>WhatDoTheyKnow is not making any requests. We are sending requests on
+<dd><p><%= site_name %> is not making any requests. We are sending requests on
behalf of our users, who are real people making the requests. </p>
<p>Look at it like this - if lots of different people made requests from
different Hotmail email addresses, then you would not think that Microsoft were
making vexatious requests. It is exactly the same if lots of requests are made
-via WhatDoTheyKnow. Moreover, since all requests are public it is much easier
+via <%= site_name %>. Moreover, since all requests are public it is much easier
for you to see if one of our users is making vexatious requests. </p>
<p>If that isn't enough for you, the
<a href="http://www.whatdotheyknow.com/request/1142/response/2894/attach/5/20080806100741260.pdf">letter from the ICO to Rother District Council</a> gives some guidance on the matter.</p>
</dd>
-<dt id="spam_problems">I can see a request on WhatDoTheyKnow, but we never got it by email!<a href="#spam_problems">#</a> </dt>
+<dt id="spam_problems">I can see a request on <%= site_name %>, but we never got it by email!<a href="#spam_problems">#</a> </dt>
<dd><p>If a request appears on the site, then we have attempted to send it to
the authority by email. Any delivery failure messages will automatically
@@ -122,7 +122,7 @@ it is best if they show the hard work they are doing by explaining what is
taking the extra time to do.
</p>
-<p>That said, WhatDoTheyKnow does show the maximum legal deadline
+<p>That said, <%= site_name %> does show the maximum legal deadline
for response on each request. Here's how we calculate it.</p>
<ul>
@@ -134,7 +134,9 @@ midnight. We then count the next working day as "day one", and so on up to
<li>If the day the request email was delivered was a non-working day, we count
the next working day as "day one". Delivery is delivery, even if it happened on
-the weekend. Some authorities <a href="http://www.whatdotheyknow.com/request/policy_regarding_body_scans#incoming-1100">disagree with this</a>, our lawyer disagrees with them. </li>
+the weekend. Some authorities
+<a href="http://www.whatdotheyknow.com/request/policy_regarding_body_scans#incoming-1100">disagree with this</a>,
+our lawyer disagrees with them. </li>
<li>Requesters are encouraged to mark when they have <strong>clarified</strong>
their request so the clock resets, but sometimes they get this wrong. If you
@@ -147,13 +149,13 @@ one case which is not normal, see the next question about
<a href="#public_interest_test">public interest test time extensions</a>.
</p>
-<p>Schools are also a special case, which WhatDoTheyKnow displays differently.
+<p>Schools are also a special case, which <%= site_name %> displays differently.
</p>
<ul>
<li>Since June 2009, <strong>schools</strong> have "20 working days
disregarding any working day which is not a school day, or 60 working days,
-whichever is first" (<a href="http://www.opsi.gov.uk/si/si2009/draft/ukdsi_9780111477632_en_1">FOI (Time for Compliance with Request) Regulations 2009</a>). WhatDoTheyKnow indicates on requests to schools that the 20 day deadline is only
+whichever is first" (<a href="http://www.opsi.gov.uk/si/si2009/draft/ukdsi_9780111477632_en_1">FOI (Time for Compliance with Request) Regulations 2009</a>). <%= site_name %> indicates on requests to schools that the 20 day deadline is only
during term time, and shows them as definitely overdue after 60 working days
</li>
</ul>
@@ -173,19 +175,19 @@ extension when applying a <strong>public interest test</strong>. Information
Commissioner guidance says that it should only be used in "exceptionally
complex" cases
(<a href="http://www.ico.gov.uk/upload/documents/library/freedom_of_information/detailed_specialist_guides/foi_good_practice_guidance_4.pdf">FOI Good Practice Guidance No. 4</a>).
-WhatDoTheyKnow doesn't specifically handle this case, which is why we use the
+<%= site_name %> doesn't specifically handle this case, which is why we use the
phrase "should normally have responded by" when the 20 working day time is
exceeded.
</p>
<p>The same guidance says that, even in exceptionally complex cases, no
Freedom of Information request should take more than <strong>40 working days</strong>
-to answer. WhatDoTheyKnow displays requests which are overdue by that much
+to answer. <%= site_name %> displays requests which are overdue by that much
with stronger wording to indicate they are definitely late.
</p>
<p>The Freedom of Information (Scotland) Act does not allow such a public
-interest extension. WhatDoTheyKnow would like to see the law changed to either
+interest extension. <%= site_name %> would like to see the law changed to either
remove the extension from the UK Act, or to reintroduce an absolute time limit
of 40 working days even with the extension (the House of Lords <a
href="http://www.publicwhip.org.uk/division.php?date=2000-10-17&amp;number=1&amp;house=lords">voted
diff --git a/app/views/help/privacy.rhtml b/app/views/help/privacy.rhtml
index 001427181..fc8c54885 100644
--- a/app/views/help/privacy.rhtml
+++ b/app/views/help/privacy.rhtml
@@ -17,7 +17,7 @@ email address to them. You will be told that this is going to happen.</p>
</dd>
<dt id="nasty_spam">Will you send nasty, brutish spam to my email address? <a href="#nasty_spam">#</a> </dt>
-<dd>Nope. After you sign up to WhatDoTheyKnow we will only send you emails
+<dd>Nope. After you sign up to <%= site_name %> we will only send you emails
relating to a request you made, an email alert that you have signed up for,
or for other reasons that you specifically authorise. We will never give or
sell your email addresses to anyone else, unless we are obliged to by law, or
@@ -123,7 +123,7 @@ give you an email address to use for that purpose.</p>
<dd>
-<p>WhatDoTheyKnow is a permanent, public archive of Freedom of
+<p><%= site_name %> is a permanent, public archive of Freedom of
Information requests. Even though you may not find the response to
a request useful any more, it may be of interest to others. For this
reason, we will not delete requests.
diff --git a/app/views/help/requesting.rhtml b/app/views/help/requesting.rhtml
index dc70f3f89..eec887950 100644
--- a/app/views/help/requesting.rhtml
+++ b/app/views/help/requesting.rhtml
@@ -11,7 +11,7 @@
<p>It can be hard to untangle government's complicated structured, and work out
who knows the information that you want. Here are a few tips:
<ul>
-<li>Browse or search WhatDoTheyKnow looking for similar requests to yours.</li>
+<li>Browse or search <%= site_name %> looking for similar requests to yours.</li>
<li>When you've found an authority you think might have the information, use
the "home page" link on the right hand side of their page to check what they do
on their website.</li>
@@ -42,7 +42,7 @@ to hear from you too.
<dt id="authorities">Why do you include some authorities that aren't formally subject to FOI?<a href="#authorities">#</a> </dt>
<dd>
-<p>WhatDoTheyKnow lets you make requests for information to a range of
+<p><%= site_name %> lets you make requests for information to a range of
organisations:</p>
<ul>
@@ -134,7 +134,7 @@ requests.
or one or two other cases, then they may have more time
(<a href="/help/officers#days">full details</a>).
-<p>WhatDoTheyKnow will email you if you don't get a timely response. You can
+<p><%= site_name %> will email you if you don't get a timely response. You can
then send the public authority a message to remind them, and tell them if they
are breaking the law.</p>
@@ -159,7 +159,7 @@ are breaking the law.</p>
</li>
<li>If they have not received it, the problem is most likely due to
"spam filters". Refer the authority to the measures in the answer
- '<a href="/help/officers#spam_problems">I can see a request on WhatDoTheyKnow, but we never got it by email!</a>'
+ '<a href="/help/officers#spam_problems">I can see a request on <%= site_name %>, but we never got it by email!</a>'
in the FOI officers section of this help.
</li>
<li>If you're still having no luck, then you can ask for an internal review,
@@ -205,7 +205,7 @@ Information Commissioner's guidance</a> for details.</p>
<dt id="data_protection">Can I request information about myself? <a href="#data_protection">#</a> </dt>
<dd>
-<p>No. Requests made using WhatDoTheyKnow are public, made under the Freedom of
+<p>No. Requests made using <%= site_name %> are public, made under the Freedom of
Information Act, and cannot help you find information about a private
individual.</p>
@@ -223,7 +223,7 @@ immediately so we can remove it.</p>
<dt id="private_requests">I'd like to keep my request secret! (At least until I publish my story) <a href="#private_requests">#</a> </dt>
-<dd><p>WhatDoTheyKnow is currently only designed for public requests. All
+<dd><p><%= site_name %> is currently only designed for public requests. All
responses that we receive are automatically published on the website for anyone
to read. </p>
<p>You should contact the public authority directly if you would like to
@@ -241,7 +241,7 @@ the Environmental Information Regulations (EIR).
</p>
<p>It's a very similar law, so you make a request
-to them using WhatDoTheyKnow in just the same way as an FOI request. The only
+to them using <%= site_name %> in just the same way as an FOI request. The only
difference is that on the page where your write you request, it reminds you
that you can only request "environmental information" and tells you what that
means. It is quite broad.
@@ -266,17 +266,17 @@ to the other authorities, you must copy and paste it by hand.
<dt id="offsite">I made a request off the site, how do I upload it to the archive?<a href="#offsite">#</a> </dt>
-<dd>WhatDoTheyKnow is an archive of requests made through the site,
+<dd><%= site_name %> is an archive of requests made through the site,
and does not try to be an archive of all FOI requests. We'll never support uploading
other requests. For one thing, we wouldn't be able to verify that other
responses actually came from the authority. If this really matters to you,
-you can always make the same request again via WhatDoTheyKnow.
+you can always make the same request again via <%= site_name %>.
</dd>
<dt id="moderation">How do you moderate request annotations? <a href="#moderation">#</a> </dt>
<dd>
-<p>Annotations on WhatDoTheyKnow are to help
+<p>Annotations on <%= site_name %> are to help
people get the information they want, or to give them pointers to places they
can go to help them act on it. We reserve the right to remove anything else.
</p>
diff --git a/app/views/help/unhappy.rhtml b/app/views/help/unhappy.rhtml
index 432c00f2e..86ded2e59 100644
--- a/app/views/help/unhappy.rhtml
+++ b/app/views/help/unhappy.rhtml
@@ -31,7 +31,7 @@ to your request '<%=request_link(@info_request) %>'?
<% if !@info_request.nil? %>
Choose <%= link_to "request an internal review", show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %> and then write a message asking the authority to review your request.
<% else %>
- At the bottom of the relevant request page on WhatDoTheyKnow choose
+ At the bottom of the relevant request page on <%= site_name %> choose
"request an internal review". Then write a message asking for an internal
review of your request. You may want to include a link to the
request page, to make it clear which request you are talking about.
@@ -64,12 +64,12 @@ Information Commissioner, either
include a link to your request
<strong><%=h main_url(request_url(@info_request)) %></strong>
<% else %>
- include a link to your request on WhatDoTheyKnow
+ include a link to your request on <%= site_name %>
<% end %>
in your complaint or print out the whole page of your request and all attachments.
</p>
-<p>WhatDoTheyKnow has no special facilities for handling a request at this stage - it
+<p><%= site_name %> has no special facilities for handling a request at this stage - it
passes into the Information Commissioner's system. You can leave annotations on your
request keeping people informed of progress.</p>
diff --git a/app/views/request/_view_html_prefix.rhtml b/app/views/request/_view_html_prefix.rhtml
index f425735cd..b29830ac7 100644
--- a/app/views/request/_view_html_prefix.rhtml
+++ b/app/views/request/_view_html_prefix.rhtml
@@ -1,6 +1,6 @@
<div class="view_html_prefix">
<div class="view_html_logo">
- <a href="/"><img src="/images/navimg/logo-trans-small.png" alt="WhatDotheyKnow?"></a>
+ <a href="/"><img src="/images/navimg/logo-trans-small.png" alt="<%= site_name %>"></a>
</div>
<div class="view_html_download_link">
<%=link_to _("Download original attachment"), @attachment_url %>
diff --git a/app/views/request/new_bad_contact.rhtml b/app/views/request/new_bad_contact.rhtml
index 41a2cef4d..56f3f4168 100644
--- a/app/views/request/new_bad_contact.rhtml
+++ b/app/views/request/new_bad_contact.rhtml
@@ -3,8 +3,8 @@
<h1><%=@title%></h1>
<p><%= _('Unfortunately, we do not have a working {{info_request_law_used_full}}
-address for'),:info_request_law_used_full => @info_request.law_used_full %> <%=h @info_request.public_body.name %>. <%= _('You may be able to find
+address for', :info_request_law_used_full => @info_request.law_used_full) %> <%=h @info_request.public_body.name %>. <%= _('You may be able to find
one on their website, or by phoning them up and asking. If you manage
-to find one, then please <a href="%s">send it to us</a>.') % [help_contact_path] %>
+to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => help_contact_path) %>
</p>
diff --git a/app/views/request/show_response.rhtml b/app/views/request/show_response.rhtml
index 40c3b3d5b..d8647d1ec 100644
--- a/app/views/request/show_response.rhtml
+++ b/app/views/request/show_response.rhtml
@@ -19,9 +19,7 @@
address</strong>, not just an email, for it to be a valid FOI request') %>
</dt>
<dd>
- <%= _('The law, the Ministry of Justice and the Information Commissioner
- all say that an email is sufficient (<a href="%s">more details</a>).
- At the bottom of this page, write a reply to the authority explaining this to them.') % [help_privacy_path + '#full_address'] %>
+ <%= render :partial => 'help/why_they_should_reply_by_email', :locals => {:help_page_url => help_privacy_path } %>
</dd>
<dt>
diff --git a/app/views/user/set_profile_about_me.rhtml b/app/views/user/set_profile_about_me.rhtml
index af6433e89..6c1edc254 100644
--- a/app/views/user/set_profile_about_me.rhtml
+++ b/app/views/user/set_profile_about_me.rhtml
@@ -26,7 +26,7 @@
<%= _(' Include relevant links, such as to a campaign page, your blog or a
twitter account. They will be made clickable.
e.g.')%>
- <a href="http://www.twitter.com/whatdotheyknow">http://www.twitter.com/whatdotheyknow</a>
+ <a href="http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>">http://www.twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %></a>
</p>
</div>
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 5e2c29d84..c3a99311a 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -110,7 +110,7 @@
<% if not @is_you %>
<p id="user_not_logged_in">
- <%= link_to _('Sign in'), signin_url(:r => request.request_uri) %><%= _('to change password,
+ <%= link_to _('Sign in'), signin_url(:r => request.request_uri) %> <%= _('to change password,
subscriptions and more')%> (<%=h @display_user.name %> <%= _('only')%>)
</p>
<% end %>
diff --git a/config/environment.rb b/config/environment.rb
index 17a16efed..606472740 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -137,3 +137,4 @@ require 'willpaginate_hack.rb'
require 'sendmail_return_path.rb'
require 'tnef.rb'
require 'i18n_fixes.rb'
+require 'rack_quote_monkeypatch.rb'
diff --git a/config/general.yml-example b/config/general.yml-example
index c832111c7..3537cd792 100644
--- a/config/general.yml-example
+++ b/config/general.yml-example
@@ -23,6 +23,9 @@ USE_DEFAULT_BROWSER_LANGUAGE: true
# How many days should have passed before an answer to a request is officially late?
REPLY_LATE_AFTER_DAYS: 20
+REPLY_VERY_LATE_AFTER_DAYS: 40
+# We give some types of authority like schools a bit longer than everyone else
+SPECIAL_REPLY_VERY_LATE_AFTER_DAYS: 60
# example searches for the home page, semicolon delimited.
FRONTPAGE_SEARCH_EXAMPLES: 'Geraldine Quango; Department for Humpadinking'
diff --git a/lib/rack_quote_monkeypatch.rb b/lib/rack_quote_monkeypatch.rb
new file mode 100644
index 000000000..be079c6a2
--- /dev/null
+++ b/lib/rack_quote_monkeypatch.rb
@@ -0,0 +1,65 @@
+# There's a bug in Rack 1.1.x which is fixed in Rack 1.2, but our
+# current version of Rails won't use that. So for now, monkeypatch,
+# This can be dropped when we move to Rails 3.
+#
+# See https://github.com/sebbacon/alaveteli/issues/38 for Alaveteli
+# bug report
+#
+# More info about the monkeypatch:
+# http://thewebfellas.com/blog/2010/7/15/rails-2-3-8-rack-1-1-and-the-curious-case-of-the-missing-quotes
+
+module Rack
+ module Utils
+ def parse_query(qs, d = nil)
+ params = {}
+
+ (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
+ k, v = p.split('=', 2).map { |x| unescape(x) }
+ if cur = params[k]
+ if cur.class == Array
+ params[k] << v
+ else
+ params[k] = [cur, v]
+ end
+ else
+ params[k] = v
+ end
+ end
+
+ return params
+ end
+ module_function :parse_query
+
+ def normalize_params(params, name, v = nil)
+ name =~ %r(\A[\[\]]*([^\[\]]+)\]*)
+ k = $1 || ''
+ after = $' || ''
+
+ return if k.empty?
+
+ if after == ""
+ params[k] = v
+ elsif after == "[]"
+ params[k] ||= []
+ raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array)
+ params[k] << v
+ elsif after =~ %r(^\[\]\[([^\[\]]+)\]$) || after =~ %r(^\[\](.+)$)
+ child_key = $1
+ params[k] ||= []
+ raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array)
+ if params[k].last.is_a?(Hash) && !params[k].last.key?(child_key)
+ normalize_params(params[k].last, child_key, v)
+ else
+ params[k] << normalize_params({}, child_key, v)
+ end
+ else
+ params[k] ||= {}
+ raise TypeError, "expected Hash (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Hash)
+ params[k] = normalize_params(params[k], after, v)
+ end
+
+ return params
+ end
+ module_function :normalize_params
+ end
+end
diff --git a/script/compact-xapian-database b/script/compact-xapian-database
index 5c12b5dae..f1a6058b0 100755
--- a/script/compact-xapian-database
+++ b/script/compact-xapian-database
@@ -1,16 +1,25 @@
#!/bin/bash
-RAILS_ENV=$1
+export RAILS_ENV=$1
set -e
+
if [ -x /usr/bin/xapian-compact ]; then
- XAPIAN_DB_DIR="$( cd "$( dirname "$0" )" && pwd )/../vendor/plugins/acts_as_xapian/xapiandbs"
- OWNER=`stat -c %U $XAPIAN_DB_DIR/$RAILS_ENV`
- su -c "xapian-compact $XAPIAN_DB_DIR/$RAILS_ENV $XAPIAN_DB_DIR/$RAILS_ENV.new" $OWNER
- mv $XAPIAN_DB_DIR/$RAILS_ENV $XAPIAN_DB_DIR/$RAILS_ENV.tmp
- mv $XAPIAN_DB_DIR/$RAILS_ENV.new $XAPIAN_DB_DIR/$RAILS_ENV
- rm -rf $XAPIAN_DB_DIR/$RAILS_ENV.tmp
- /etc/init.d/apache2 restart
+ XAPIAN_DB_DIR=$( cd "$( dirname "$0" )" && pwd )/../vendor/plugins/acts_as_xapian/xapiandbs
+ if [ -e "$XAPIAN_DB_DIR/$RAILS_ENV.new" ]; then
+ echo >&2 "Didn't compact Xapian database because there was an existing database at $XAPIAN_DB_DIR/$RAILS_ENV.new"
+ exit 1
+ else
+ OWNER=$(stat -c %U "$XAPIAN_DB_DIR/$RAILS_ENV")
+ export XAPIAN_DB_DIR RAILS_ENV
+ su "$OWNER" <<SU
+ xapian-compact "\$XAPIAN_DB_DIR/\$RAILS_ENV" "\$XAPIAN_DB_DIR/\$RAILS_ENV.new"
+SU
+ mv "$XAPIAN_DB_DIR/$RAILS_ENV" "$XAPIAN_DB_DIR/$RAILS_ENV.tmp"
+ mv "$XAPIAN_DB_DIR/$RAILS_ENV.new" "$XAPIAN_DB_DIR/$RAILS_ENV"
+ rm -rf "$XAPIAN_DB_DIR/$RAILS_ENV.tmp"
+ /etc/init.d/apache2 restart
+ fi
else
- echo "Could not find xapian-compact script; have you installed xapian-tools?"
+ echo >&2 "Could not find xapian-compact script; have you installed xapian-tools?"
exit 1
-fi \ No newline at end of file
+fi
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb
index 357564211..53db4f412 100644
--- a/spec/controllers/admin_public_body_controller_spec.rb
+++ b/spec/controllers/admin_public_body_controller_spec.rb
@@ -109,28 +109,34 @@ describe AdminPublicBodyController, "when administering public bodies with i18n"
get :show, {:id => 2, :locale => "es" }
end
- it "creates a new public body" do
- I18n.default_locale = :es
- PublicBody.count.should == 2
- post :create, { :public_body => { :name => "New Quango", :short_name => "", :tag_string => "blah", :request_email => 'newquango@localhost', :last_edit_comment => 'From test code' } }
- PublicBody.count.should == 3
- I18n.default_locale = :en
- end
-
it "edits a public body" do
- I18n.default_locale = :es
- get :edit, {:id => 3, :locale => :es}
- response.body.should include('Baguette')
- I18n.default_locale = :en
+ get :edit, {:id => 3, :locale => :en}
+
+ # When editing a body, the controller returns all available translations
+ assigns[:public_body].translation("es").name.should == 'El Department for Humpadinking'
+ assigns[:public_body].name.should == 'Department for Humpadinking'
+ response.should render_template('edit')
end
it "saves edits to a public body" do
- I18n.default_locale = :es
- pb = PublicBody.find(id=3)
- pb.name.should == "El Department for Humpadinking"
- post :update, { :id => 3, :public_body => { :name => "Renamed", :short_name => "", :tag_string => "some tags", :request_email => 'edited@localhost', :last_edit_comment => 'From test code' }}
- response.flash[:notice].should include('successful')
- I18n.default_locale = :en
+ PublicBody.with_locale(:es) do
+ pb = PublicBody.find(id=3)
+ pb.name.should == "El Department for Humpadinking"
+ post :update, {
+ :id => 3,
+ :public_body => {
+ :name => "Department for Humpadinking",
+ :short_name => "",
+ :tag_string => "some tags",
+ :request_email => 'edited@localhost',
+ :last_edit_comment => 'From test code',
+ :translated_versions => {
+ 3 => {:locale => "es", :name => "Renamed",:short_name => "", :request_email => 'edited@localhost'}
+ }
+ }
+ }
+ response.flash[:notice].should include('successful')
+ end
pb = PublicBody.find(public_bodies(:humpadink_public_body).id)
PublicBody.with_locale(:es) do
@@ -148,3 +154,51 @@ describe AdminPublicBodyController, "when administering public bodies with i18n"
end
end
+
+describe AdminPublicBodyController, "when creating public bodies with i18n" do
+ integrate_views
+ fixtures :public_bodies, :public_body_translations
+
+ before do
+ username = MySociety::Config.get('ADMIN_USERNAME', '')
+ password = MySociety::Config.get('ADMIN_PASSWORD', '')
+ basic_auth_login @request
+
+ ActionController::Routing::Routes.filters.clear # don't auto-insert locale, complicates assertions
+ end
+
+ it "creates a new public body in one locale" do
+ PublicBody.count.should == 2
+ post :create, { :public_body => { :name => "New Quango", :short_name => "", :tag_string => "blah", :request_email => 'newquango@localhost', :last_edit_comment => 'From test code' } }
+ PublicBody.count.should == 3
+
+ body = PublicBody.find_by_name("New Quango")
+ response.should redirect_to(:controller=>'admin_public_body', :action=>'show', :id=>body.id)
+ end
+
+ it "creates a new public body with multiple locales" do
+ PublicBody.count.should == 2
+ post :create, {
+ :public_body => {
+ :name => "New Quango", :short_name => "", :tag_string => "blah", :request_email => 'newquango@localhost', :last_edit_comment => 'From test code',
+ :translated_versions => [{ :locale => "es", :name => "Mi Nuevo Quango", :short_name => "", :request_email => 'newquango@localhost' }]
+ }
+ }
+ PublicBody.count.should == 3
+
+ body = PublicBody.find_by_name("New Quango")
+ body.translations.map {|t| t.locale.to_s}.sort.should == ["en", "es"]
+ PublicBody.with_locale(:en) do
+ body.name.should == "New Quango"
+ body.url_name.should == "new_quango"
+ body.first_letter.should == "N"
+ end
+ PublicBody.with_locale(:es) do
+ body.name.should == "Mi Nuevo Quango"
+ body.url_name.should == "mi_nuevo_quango"
+ body.first_letter.should == "M"
+ end
+
+ response.should redirect_to(:controller=>'admin_public_body', :action=>'show', :id=>body.id)
+ end
+end
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index 76e1bb5e6..3640a8148 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -62,7 +62,6 @@ describe GeneralController, "when searching" do
response.should be_success
end
-
it "should redirect from search query URL to pretty URL" do
post :search_redirect, :query => "mouse" # query hidden in POST parameters
response.should redirect_to(:action => 'search', :combined => "mouse") # URL /search/:query
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 500a30bd0..caca03d58 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -308,6 +308,13 @@ describe RequestController, "when creating a new request" do
response.should redirect_to(:controller => 'general', :action => 'frontpage')
end
+ it "should redirect 'bad request' page when a body has no email address" do
+ @body.request_email = ""
+ @body.save!
+ get :new, :public_body_id => @body.id
+ response.should render_template('new_bad_contact')
+ end
+
it "should accept a public body parameter" do
get :new, :public_body_id => @body.id
assigns[:info_request].public_body.should == @body
@@ -779,6 +786,8 @@ describe RequestController, "when classifying an information request" do
@dog_request.stub!(:date_very_overdue_after).and_return(Time.now.to_date-1)
expect_redirect('waiting_response', unhappy_url)
flash[:notice].should match(/is long overdue/)
+ flash[:notice].should match(/by more than 40 working days/)
+ flash[:notice].should match(/within 20 working days/)
end
it 'should redirect to the "request url" when status is updated to "not held"' do
diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb
new file mode 100644
index 000000000..9398519b7
--- /dev/null
+++ b/spec/integration/search_request_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe "When searching" do
+ it "should not strip quotes from quoted query" do
+ request_via_redirect("post", "/search", :query => '"mouse stilton"')
+ response.body.should include("&quot;mouse stilton&quot;")
+ end
+end
+
diff --git a/spec/lib/i18n_interpolation.rb b/spec/lib/i18n_interpolation.rb
new file mode 100644
index 000000000..8c86413ad
--- /dev/null
+++ b/spec/lib/i18n_interpolation.rb
@@ -0,0 +1,15 @@
+# This is a test of the set_content_type monkey patch in
+# lib/tmail_extensions.rb
+
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe "when using i18n" do
+
+ it "should not complain if we're missing variables from the string" do
+ result = _('Hello', :dip => 'hummus')
+ result.should == 'Hello'
+ result = _('Hello {{dip}}', :dip => 'hummus')
+ result.should == 'Hello hummus'
+ end
+end
+
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index 5fcc534ca..183a258af 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -19,6 +19,13 @@ describe IncomingMessage, " when dealing with incoming mail" do
end
+describe IncomingMessage, "when parsing HTML mail" do
+ it "should display UTF-8 characters in the plain text version correctly" do
+ html = "<html><b>foo</b> është"
+ plain_text = IncomingMessage._get_attachment_text_internal_one_file('text/html', html)
+ plain_text.should match(/është/)
+ end
+end
describe IncomingMessage, "when getting the attachment text" do
@@ -201,6 +208,13 @@ describe IncomingMessage, " when censoring data" do
data.should == "There was a mouse called Jarlsberg, he wished that he was yellow."
end
+ it "should apply hard-coded privacy rules to HTML files" do
+ domain = MySociety::Config.get('DOMAIN')
+ data = "http://#{domain}/c/cheese"
+ @im.html_mask_stuff!(data)
+ data.should == "[WDTK login link]"
+ end
+
it "should apply censor rules to From: addresses" do
mock_mail = mock('Email object')
mock_mail.stub!(:from_name_if_present).and_return("Stilton Mouse")
diff --git a/spec/models/outgoing_message_spec.rb b/spec/models/outgoing_message_spec.rb
index a9ef57b4f..1956c4d73 100644
--- a/spec/models/outgoing_message_spec.rb
+++ b/spec/models/outgoing_message_spec.rb
@@ -1,7 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe OutgoingMessage, " when making an outgoing message" do
+ fixtures :outgoing_messages, :info_requests, :incoming_messages, :public_bodies, :public_body_translations
+
before do
+ @om = outgoing_messages(:useless_outgoing_message)
@outgoing_message = OutgoingMessage.new({
:status => 'ready',
:message_type => 'initial_request',
@@ -27,6 +30,10 @@ describe OutgoingMessage, " when making an outgoing message" do
it "should include email addresses in outgoing messages" do
@outgoing_message.body.should include("foo@bar.com")
end
+
+ it "should work out a salutation" do
+ @om.get_salutation.should == "Dear Geraldine Quango,"
+ end
end
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index ec84cbe65..3d00d37fb 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -210,6 +210,20 @@ describe PublicBody, "when searching" do
body.id.should == 3
body.class.to_s.should == 'PublicBody'
end
+
+ it "should cope with same url_name across multiple locales" do
+ PublicBody.with_locale(:es) do
+ # use the unique spanish name to retrieve and edit
+ body = PublicBody.find_by_url_name_with_historic('etgq')
+ body.short_name = 'tgq' # Same as english version
+ body.save!
+
+ # now try to retrieve it
+ body = PublicBody.find_by_url_name_with_historic('tgq')
+ body.id.should == public_bodies(:geraldine_public_body).id
+ body.name.should == "El A Geraldine Quango"
+ end
+ end
end
describe PublicBody, " when loading CSV files" do