aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--.ruby-version.example (renamed from .ruby-version)0
-rw-r--r--Gemfile6
-rw-r--r--Gemfile.lock6
-rw-r--r--README.md24
-rw-r--r--app/controllers/admin_general_controller.rb3
-rw-r--r--app/controllers/application_controller.rb1
-rw-r--r--app/controllers/request_game_controller.rb3
-rw-r--r--app/mailers/request_mailer.rb14
-rw-r--r--app/models/info_request.rb7
-rw-r--r--app/models/outgoing_message.rb2
-rw-r--r--app/models/user.rb1
-rw-r--r--app/views/admin_public_body/edit.html.erb2
-rw-r--r--app/views/request/_request_listing_single.html.erb18
-rw-r--r--app/views/request_game/play.html.erb24
-rw-r--r--config/initializers/alaveteli.rb2
-rw-r--r--locale/es_NI/app.po6
-rw-r--r--spec/controllers/general_controller_spec.rb1
-rw-r--r--spec/mailers/request_mailer_spec.rb46
-rw-r--r--spec/models/info_request_spec.rb1
20 files changed, 124 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
index 99c1ba9ff..78a06c661 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,9 @@
._*
.DS_Store
.autotest
+.ruby-version
+.rbenv-version
+.rvmrc
*#*#
TAGS
/lib/themes
diff --git a/.ruby-version b/.ruby-version.example
index 7fa1d1ef4..7fa1d1ef4 100644
--- a/.ruby-version
+++ b/.ruby-version.example
diff --git a/Gemfile b/Gemfile
index 07cbdce9f..c4ac74273 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,7 +5,7 @@ gem 'rails', '3.2.21'
gem 'pg', '~> 0.17.1'
# New gem releases aren't being done. master is newer and supports Rails > 3.0
-gem 'acts_as_versioned', :git => 'git://github.com/technoweenie/acts_as_versioned.git', :ref => '63b1fc8529d028'
+gem 'acts_as_versioned', :git => 'https://github.com/technoweenie/acts_as_versioned.git', :ref => '63b1fc8529d028'
gem 'charlock_holmes', '~> 0.6.9.4'
gem 'dynamic_form', '~> 1.1.4'
gem 'exception_notification', '~> 3.0.1'
@@ -27,7 +27,7 @@ gem 'rake', '0.9.2.2'
gem 'rails-i18n', '~> 0.7.3'
gem 'recaptcha', '~> 0.3.1', :require => 'recaptcha/rails'
gem 'rmagick', '~> 2.14.0'
-gem 'ruby-msg', '~> 1.5.0', :git => 'git://github.com/mysociety/ruby-msg.git'
+gem 'ruby-msg', '~> 1.5.0', :git => 'https://github.com/mysociety/ruby-msg.git'
gem 'secure_headers', '~> 1.3.4'
gem 'statistics2', '~> 0.54'
gem 'syslog_protocol', '~> 0.9.2'
@@ -43,7 +43,7 @@ gem 'zip', '~> 2.0.2'
gem 'fast_gettext', '~> 0.7.0'
gem 'gettext_i18n_rails', '~> 0.9.4'
gem 'gettext', '~> 2.3.9'
-gem 'globalize3', :git => 'git://github.com/globalize/globalize.git', :ref => '5fd95f2389dff1'
+gem 'globalize3', :git => 'https://github.com/globalize/globalize.git', :ref => '5fd95f2389dff1'
gem 'locale', '~> 2.0.8'
gem 'routing-filter', '~> 0.3.1'
gem 'unicode', '~> 0.4.4'
diff --git a/Gemfile.lock b/Gemfile.lock
index 32b09a723..f00c26061 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,5 +1,5 @@
GIT
- remote: git://github.com/globalize/globalize.git
+ remote: https://github.com/globalize/globalize.git
revision: 5fd95f2389dff13c9368fb2e08c96c8a48798c72
ref: 5fd95f2389dff1
specs:
@@ -9,7 +9,7 @@ GIT
paper_trail (~> 2)
GIT
- remote: git://github.com/mysociety/ruby-msg.git
+ remote: https://github.com/mysociety/ruby-msg.git
revision: ee0086add16c755d2eaf8dbcb90ba65809061cef
specs:
ruby-msg (1.5.2)
@@ -17,7 +17,7 @@ GIT
vpim (>= 0.360)
GIT
- remote: git://github.com/technoweenie/acts_as_versioned.git
+ remote: https://github.com/technoweenie/acts_as_versioned.git
revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b
ref: 63b1fc8529d028
specs:
diff --git a/README.md b/README.md
index de025dcb2..d3d08f718 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,22 @@ wiki](https://github.com/mysociety/alaveteli/wiki/Home/), and upgrade
notes in the [`doc/`
folder](https://github.com/mysociety/alaveteli/tree/master/doc/CHANGES.md)
+## Installing
+
+We've been working hard to make Alaveteli easy to install and re-use anywhere. Please
+see [the project website](http://alaveteli.org) for instructions on installing Alaveteli.
+
+## Compatibility
+
+Every Alaveteli commit is tested by Travis on the [following Ruby platforms](https://github.com/mysociety/alaveteli/blob/master/.travis.yml#L7)
+
+* ruby-1.8.7
+* ruby-1.9.3
+* ruby-2.0.0
+
+
+If you use a ruby version management tool (such as RVM or .rbenv) and want to use the default development version used by the alaveteli team (currently 2.0.0), you can create a `.ruby-version` symlink with a target of `.ruby-version.example` to switch to that automatically in the project directory.
+
## How to contribute
If you find what looks like a bug:
@@ -44,3 +60,11 @@ If you want to contribute an enhancement or a fix:
Looking for the latest stable release? It's on the
[master branch](https://github.com/mysociety/alaveteli/tree/master).
+We have some more notes for developers [on the project site](http://alaveteli.org/docs/developers/).
+
+## Examples
+
+* [WhatDoTheyKnow](https://www.whatdotheyknow.com)
+* [KiMitTud](http://kimittud.atlatszo.hu)
+* [Informace Pro Všechny](http://www.infoprovsechny.cz)
+* [fyi.org.nz](https://fyi.org.nz)
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb
index f2414eeab..13edec37d 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.rb
@@ -23,8 +23,7 @@ class AdminGeneralController < AdminController
@requires_admin_requests = InfoRequest.find_in_state('requires_admin')
@error_message_requests = InfoRequest.find_in_state('error_message')
@attention_requests = InfoRequest.find_in_state('attention_requested')
- @blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"],
- :order => "updated_at")
+ @blank_contacts = PublicBody.where(:request_email => "").order(:updated_at).select { |pb| !pb.defunct? }
@old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,
:conditions => ["prominence = 'normal'"])
@holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 044f8e10f..e80c6a823 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -132,7 +132,6 @@ class ApplicationController < ActionController::Base
def validate_session_timestamp
if session[:user_id] && session.key?(:ttl) && session[:ttl] < SESSION_TTL.ago
clear_session_credentials
- redirect_to signin_path
end
end
diff --git a/app/controllers/request_game_controller.rb b/app/controllers/request_game_controller.rb
index 298818bc7..7eadc1204 100644
--- a/app/controllers/request_game_controller.rb
+++ b/app/controllers/request_game_controller.rb
@@ -13,7 +13,8 @@ class RequestGameController < ApplicationController
@total = InfoRequest.count
@done = @total - @missing
@percentage = (@done.to_f / @total.to_f * 10000).round / 100.0
- @requests = InfoRequest.get_random_old_unclassified(3, :conditions => ["prominence = 'normal'"])
+ @requests = InfoRequest.includes(:public_body, :user).get_random_old_unclassified(3, :conditions => ["prominence = 'normal'"])
+
if @missing == 0
flash[:notice] = _('<p>All done! Thank you very much for your help.</p><p>There are <a href="{{helpus_url}}">more things you can do</a> to help {{site_name}}.</p>',
diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb
index c9decc6db..bf04b1ab9 100644
--- a/app/mailers/request_mailer.rb
+++ b/app/mailers/request_mailer.rb
@@ -64,7 +64,7 @@ class RequestMailer < ApplicationMailer
mail(:from => user.name_and_email,
:to => contact_from_name_and_email,
- :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title).html_safe)
+ :subject => _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title.html_safe))
end
# Tell the requester that a new response has arrived
@@ -80,7 +80,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("New response to your FOI request - ") + info_request.title).html_safe,
+ :subject => _("New response to your FOI request - ") + info_request.title.html_safe,
:charset => "UTF-8",
# not much we can do if the user's email is broken
:reply_to => contact_from_name_and_email)
@@ -105,7 +105,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => user.name_and_email,
- :subject => (_("Delayed response to your FOI request - ") + info_request.title).html_safe)
+ :subject => _("Delayed response to your FOI request - ") + info_request.title.html_safe)
end
# Tell the requester that the public body is very late in replying
@@ -125,7 +125,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => user.name_and_email,
- :subject => (_("You're long overdue a response to your FOI request - ") + info_request.title).html_safe)
+ :subject => _("You're long overdue a response to your FOI request - ") + info_request.title.html_safe)
end
# Tell the requester that they need to say if the new response
@@ -183,7 +183,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("Clarify your FOI request - ") + info_request.title).html_safe)
+ :subject => _("Clarify your FOI request - ") + info_request.title.html_safe)
end
# Tell requester that somebody add an annotation to their request
@@ -197,7 +197,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("Somebody added a note to your FOI request - ") + info_request.title).html_safe)
+ :subject => _("Somebody added a note to your FOI request - ") + info_request.title.html_safe)
end
def comment_on_alert_plural(info_request, count, earliest_unalerted_comment)
@count, @info_request = count, info_request
@@ -209,7 +209,7 @@ class RequestMailer < ApplicationMailer
mail(:from => contact_from_name_and_email,
:to => info_request.user.name_and_email,
- :subject => (_("Some notes have been added to your FOI request - ") + info_request.title).html_safe)
+ :subject => _("Some notes have been added to your FOI request - ") + info_request.title.html_safe)
end
# Class function, called by script/mailin with all incoming responses.
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 505b9d140..f9f6cffa9 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -804,11 +804,8 @@ public
# Text from the the initial request, for use in summary display
def initial_request_text
- if outgoing_messages.empty? # mainly for use with incomplete fixtures
- return ""
- end
- excerpt = self.outgoing_messages[0].get_text_for_indexing
- return excerpt
+ return '' if outgoing_messages.empty? # mainly for use with incomplete fixtures
+ outgoing_messages.first.get_text_for_indexing
end
# Returns index of last event which is described or nil if none described.
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index fa83c7381..c2c8ef4f2 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -302,7 +302,7 @@ class OutgoingMessage < ActiveRecord::Base
end
def set_default_letter
- self.body = get_default_message if body.nil?
+ self.body = get_default_message if raw_body.nil?
end
def format_of_body
diff --git a/app/models/user.rb b/app/models/user.rb
index 920c0da46..1fb5d9139 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -38,6 +38,7 @@ class User < ActiveRecord::Base
has_one :profile_photo
has_many :censor_rules, :order => 'created_at desc'
has_many :info_request_batches, :order => 'created_at desc'
+ has_many :request_classifications
validates_presence_of :email, :message => _("Please enter your email address")
validates_presence_of :name, :message => _("Please enter your name")
diff --git a/app/views/admin_public_body/edit.html.erb b/app/views/admin_public_body/edit.html.erb
index dcafbd270..fc9c25e8f 100644
--- a/app/views/admin_public_body/edit.html.erb
+++ b/app/views/admin_public_body/edit.html.erb
@@ -13,7 +13,7 @@
<div class="row">
<div class="span8">
<div class="well">
- <%= link_to 'Show', admin_bodies_path(@public_body), :class => "btn" %>
+ <%= link_to 'Show', admin_body_path(@public_body), :class => "btn" %>
<%= link_to 'List all', admin_bodies_path, :class => "btn" %>
</div>
</div>
diff --git a/app/views/request/_request_listing_single.html.erb b/app/views/request/_request_listing_single.html.erb
index 50f889d75..0f1d7f4ef 100644
--- a/app/views/request/_request_listing_single.html.erb
+++ b/app/views/request/_request_listing_single.html.erb
@@ -2,14 +2,20 @@
<span class="head">
<%= link_to h(info_request.title), (@play_urls ? categorise_request_path(:url_title => info_request.url_title) : request_path(info_request)) %>
</span>
+
<span class="desc">
<%= excerpt(info_request.initial_request_text, "", :radius => 150) %>
- </span>
- <span class="bottomline icon_<%= info_request.calculate_status %>">
- <strong>
+ </span>
+
+ <span class="bottomline icon_<%= info_request.calculate_status %>">
+ <strong>
<%= info_request.display_status %>
- </strong><br>
- <%= _('Requested from {{public_body_name}} by {{info_request_user}} on {{date}}',:public_body_name=>public_body_link(info_request.public_body),:info_request_user=>user_link(info_request.user),:date=>simple_date(info_request.created_at)) %>
- </span>
+ </strong>
+ <br>
+ <%= _('Requested from {{public_body_name}} by {{info_request_user}} on {{date}}',
+ :public_body_name => public_body_link(info_request.public_body),
+ :info_request_user => user_link(info_request.user),
+ :date => simple_date(info_request.created_at)) %>
+ </span>
</div>
diff --git a/app/views/request_game/play.html.erb b/app/views/request_game/play.html.erb
index 783bb7f00..44fe641f9 100644
--- a/app/views/request_game/play.html.erb
+++ b/app/views/request_game/play.html.erb
@@ -10,43 +10,47 @@
%>
<br><%=pluralize(@missing, 'request')%> left to categorise / <%=@total %> total
</p>
+
<h2>Top recent players</h2>
<table>
- <% c = 0; for classifications in @league_table_28_days %>
+ <% @league_table_28_days.each_with_index do |classifications, index| %>
<tr>
- <td> <%= c += 1 %>. <td>
+ <td> <%= index += 1 %>. <td>
<td> <%= user_link(classifications.user) %> </td>
- <td> <%=pluralize(classifications.cnt, 'request').gsub(" ", "&nbsp;").html_safe %> </td>
+ <td> <%= pluralize(classifications.cnt, 'request').gsub(" ", "&nbsp;").html_safe %> </td>
</tr>
<% end %>
</table>
<h2>All time best players</h2>
<table>
- <% c = 0; for classifications in @league_table_all_time %>
+ <% @league_table_all_time.each_with_index do |classifications, index| %>
<tr>
- <td> <%= c += 1 %>. <td>
+ <td> <%= index += 1 %>. <td>
<td> <%= user_link(classifications.user) %> </td>
<td> <%= pluralize(classifications.cnt, 'request').gsub(" ", "&nbsp;").html_safe %> </td>
</tr>
<% end %>
</table>
</div>
+
<div id="game">
<h2><%= _("Play the request categorisation game!")%></h2>
+
<p><%= _("Some people who've made requests haven't let us know whether they were
successful or not. We need <strong>your</strong> help &ndash;
choose one of these requests, read it, and let everyone know whether or not the
information has been provided. Everyone'll be exceedingly grateful.")%></p>
- <% for info_request in @requests %>
+
+ <% @requests.each do |info_request| %>
<%= render :partial => 'request/request_listing_single', :locals => { :info_request => info_request } %>
<% end %>
+
<p id="game_buttons">
- <%= button_to _('I don\'t like these ones &mdash; give me some more!'), categorise_play_url %>
- <%= button_to _('I don\'t want to do any more tidying now!'), categorise_stop_url %>
+ <%= button_to _('I don\'t like these ones &mdash; give me some more!'), categorise_play_url %>
+ <%= button_to _('I don\'t want to do any more tidying now!'), categorise_stop_url %>
</p>
+
<p><%= _('Thanks for helping - your work will make it easier for everyone to find successful
responses, and maybe even let us make league tables...')%></p>
</div>
-
-
diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb
index 9787785db..d09bfec28 100644
--- a/config/initializers/alaveteli.rb
+++ b/config/initializers/alaveteli.rb
@@ -10,7 +10,7 @@ load "debug_helpers.rb"
load "util.rb"
# Application version
-ALAVETELI_VERSION = '0.21.0.20'
+ALAVETELI_VERSION = '0.21.0.23'
# Add new inflection rules using the following format
# (all these examples are active by default):
diff --git a/locale/es_NI/app.po b/locale/es_NI/app.po
index 2f6ad5a56..027562a91 100644
--- a/locale/es_NI/app.po
+++ b/locale/es_NI/app.po
@@ -19,8 +19,8 @@ msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-03-24 10:21+0000\n"
-"PO-Revision-Date: 2015-04-17 03:06+0000\n"
-"Last-Translator: jbaezni <jbaezni@gmail.com>\n"
+"PO-Revision-Date: 2015-04-24 16:21+0000\n"
+"Last-Translator: Gareth Rees <gareth@mysociety.org>\n"
"Language-Team: Spanish (Nicaragua) (http://www.transifex.com/projects/p/alaveteli/language/es_NI/)\n"
"Language: es_NI\n"
"MIME-Version: 1.0\n"
@@ -3757,7 +3757,7 @@ msgstr[0] "Sus {{count}} solicitudes por bloques"
msgstr[1] "Sus {{count}} solicitudes por bloques"
msgid "Your {{law_used_full}} request has been sent"
-msgstr "Su {{law_used_full}} ha sido enviada"
+msgstr "Su solicitud de {{law_used_full}} ha sido enviada"
msgid "Your {{site_name}} email alert"
msgstr "Tu alerta en {{site_name}}"
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index ae8d4f256..844fcd4e6 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -169,7 +169,6 @@ describe GeneralController, "when showing the frontpage" do
it 'should end a logged-in session whose ttl has expired' do
session[:ttl] = Time.now - 4.hours
get :frontpage
- response.should redirect_to signin_path
session[:user_id].should be_nil
end
diff --git a/spec/mailers/request_mailer_spec.rb b/spec/mailers/request_mailer_spec.rb
index 9e98dbc00..6b54c25d2 100644
--- a/spec/mailers/request_mailer_spec.rb
+++ b/spec/mailers/request_mailer_spec.rb
@@ -1,6 +1,8 @@
# encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+# TODO: Combine all these separate "describe" blocks to tidy things up
+
describe RequestMailer, " when receiving incoming mail" do
before(:each) do
load_raw_emails_data
@@ -411,6 +413,10 @@ describe RequestMailer, 'when sending a new response email' do
@mail = RequestMailer.new_response(@info_request, @incoming_message)
end
+ it 'should not create HTML entities in the subject line' do
+ mail = RequestMailer.new_response(FactoryGirl.create(:info_request, :title => "Here's a request"), FactoryGirl.create(:incoming_message))
+ expect(mail.subject).to eq "New response to your FOI request - Here's a request"
+ end
end
describe RequestMailer, 'requires_admin' do
@@ -419,7 +425,7 @@ describe RequestMailer, 'requires_admin' do
:name => 'Bruce Jones')
@info_request = mock_model(InfoRequest, :user => user,
:described_state => 'error_message',
- :title => 'Test request',
+ :title => "It's a Test request",
:url_title => 'test_request',
:law_used_short => 'FOI',
:id => 123)
@@ -435,4 +441,42 @@ describe RequestMailer, 'requires_admin' do
mail.body.should include 'Something has gone wrong'
end
+ it 'should not create HTML entities in the subject line' do
+ expect(RequestMailer.requires_admin(@info_request).subject).to eq "FOI response requires admin (error_message) - It's a Test request"
+ end
+end
+
+describe RequestMailer, "overdue_alert" do
+ it 'should not create HTML entities in the subject line' do
+ mail = RequestMailer.overdue_alert(FactoryGirl.create(:info_request, :title => "Here's a request"), FactoryGirl.create(:user))
+ expect(mail.subject).to eq "Delayed response to your FOI request - Here's a request"
+ end
+end
+
+describe RequestMailer, "very_overdue_alert" do
+ it 'should not create HTML entities in the subject line' do
+ mail = RequestMailer.very_overdue_alert(FactoryGirl.create(:info_request, :title => "Here's a request"), FactoryGirl.create(:user))
+ expect(mail.subject).to eq "You're long overdue a response to your FOI request - Here's a request"
+ end
+end
+
+describe RequestMailer, "not_clarified_alert" do
+ it 'should not create HTML entities in the subject line' do
+ mail = RequestMailer.not_clarified_alert(FactoryGirl.create(:info_request, :title => "Here's a request"), FactoryGirl.create(:incoming_message))
+ expect(mail.subject).to eq "Clarify your FOI request - Here's a request"
+ end
+end
+
+describe RequestMailer, "comment_on_alert" do
+ it 'should not create HTML entities in the subject line' do
+ mail = RequestMailer.comment_on_alert(FactoryGirl.create(:info_request, :title => "Here's a request"), FactoryGirl.create(:comment))
+ expect(mail.subject).to eq "Somebody added a note to your FOI request - Here's a request"
+ end
+end
+
+describe RequestMailer, "comment_on_alert_plural" do
+ it 'should not create HTML entities in the subject line' do
+ mail = RequestMailer.comment_on_alert_plural(FactoryGirl.create(:info_request, :title => "Here's a request"), 2, FactoryGirl.create(:comment))
+ expect(mail.subject).to eq "Some notes have been added to your FOI request - Here's a request"
+ end
end
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index c8bd2c338..d8c0c59b1 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -1221,6 +1221,7 @@ describe InfoRequest do
describe InfoRequest, "when constructing a list of requests by query" do
before(:each) do
+ load_raw_emails_data
get_fixtures_xapian_index
end