diff options
30 files changed, 340 insertions, 119 deletions
diff --git a/.gitignore b/.gitignore index 537a7abf2..a4ec2380e 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ webrat.log /db/development_structure.sql /db/structure.sql /public/assets +.vagrant diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 000000000..dcdf1f433 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,87 @@ +# Welcome! Thanks for taking an interest in contributing to Alaveteli. +# This Vagrantfile should get you started with the minimum of fuss. +# +# Usage +# ===== +# +# Get a copy of Alaveteli from GitHub and create the Vagrant instance +# +# # Host +# $ git clone git@github.com:mysociety/alaveteli.git +# $ cd alaveteli +# $ git submodule update --init +# $ vagrant --no-color up +# +# You should now be able to ssh in to the guest and run the test suite +# +# # Host +# $ vagrant ssh +# +# # Guest +# $ cd /home/vagrant/alaveteli +# $ bundle exec rake spec +# +# Run the rails server and visit the application in your host browser +# at http://10.10.10.30:3000 +# +# # Guest +# bundle exec rails s +# +# Customizing the Vagrant instance +# ================================ +# +# This Vagrantfile allows customisation of some aspects of the virtaual machine +# See the customization options below for details. +# +# The options can be set either by prefixing the vagrant command, or by +# exporting to the environment. +# +# # Prefixing the command +# $ ALAVETELI_MEMORY=2048 vagrant up +# +# # Exporting to the environment +# $ export ALAVETELI_MEMORY=2048 +# $ vagrant up +# +# Both have the same effect, but exporting will retain the variable for the +# duration of your shell session. +# +# Customization Options +# ===================== +ALAVETELI_FQDN = ENV['ALAVETELI_VAGRANT_FQDN'] || "alaveteli.10.10.10.30.xip.io" +ALAVETELI_MEMORY = ENV['ALAVETELI_VAGRANT_MEMORY'] || 1536 +ALAVETELI_THEMES_DIR = ENV['ALAVETELI_THEMES_DIR'] || '../alaveteli-themes' + +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.box = "precise64" + config.vm.box_url = "http://files.vagrantup.com/precise64.box" + config.vm.network :private_network, :ip => "10.10.10.30" + + config.vm.synced_folder ".", "/home/vagrant/alaveteli", :owner => "vagrant", :group => "vagrant" + + if File.directory?(ALAVETELI_THEMES_DIR) + config.vm.synced_folder ALAVETELI_THEMES_DIR, + "/home/vagrant/alaveteli-themes", + :owner => "vagrant", + :group => "vagrant" + end + + config.ssh.forward_agent = true + + # The bundle install fails unless you have quite a large amount of + # memory; insist on 1.5GiB: + config.vm.provider "virtualbox" do |vb| + vb.customize ["modifyvm", :id, "--memory", ALAVETELI_MEMORY] + end + + # Fetch and run the install script: + config.vm.provision :shell, :inline => "wget -O install-site.sh https://raw.github.com/mysociety/commonlib/master/bin/install-site.sh" + config.vm.provision :shell, :inline => "chmod a+rx install-site.sh" + config.vm.provision :shell, :inline => "./install-site.sh " \ + "--dev " \ + "alaveteli " \ + "vagrant " \ + "#{ ALAVETELI_FQDN }" +end diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index cda56a211..5e39c3a2c 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -6,34 +6,18 @@ class CommentController < ApplicationController before_filter :check_read_only, :only => [ :new ] + before_filter :find_info_request, :only => [ :new ] + before_filter :create_track_thing, :only => [ :new ] + before_filter :reject_unless_comments_allowed, :only => [ :new ] + before_filter :reject_if_user_banned, :only => [ :new ] protect_from_forgery :only => [ :new ] def new - if params[:type] == 'request' - @info_request = InfoRequest.find_by_url_title!(params[:url_title]) - @track_thing = TrackThing.create_track_for_request(@info_request) - if params[:comment] - @comment = Comment.new(params[:comment].merge({ - :comment_type => 'request', - :user => @user - })) - end - else - raise "Unknown type " + params[:type] - end - - # Are comments disabled on this request? - # - # There is no “add comment” link when comments are disabled, so users should - # not usually hit this unless they are explicitly attempting to avoid the comment - # block, so we just raise an exception. - raise "Comments are not allowed on this request" if !@info_request.comments_allowed? - - # Banned from adding comments? - if !authenticated_user.nil? && !authenticated_user.can_make_comments? - @details = authenticated_user.can_fail_html - render :template => 'user/banned' - return + if params[:comment] + @comment = Comment.new(params[:comment].merge({ + :comment_type => 'request', + :user => @user + })) end if params[:comment] @@ -92,5 +76,36 @@ class CommentController < ApplicationController end end -end + private + def find_info_request + if params[:type] == 'request' + @info_request = InfoRequest.find_by_url_title!(params[:url_title]) + else + raise "Unknown type #{ params[:type] }" + end + end + + def create_track_thing + @track_thing = TrackThing.create_track_for_request(@info_request) + end + + # Are comments disabled on this request? + # + # There is no “add comment” link when comments are disabled, so users should + # not usually hit this unless they are explicitly attempting to avoid the comment block + def reject_unless_comments_allowed + unless @info_request.comments_allowed? + redirect_to request_url(@info_request), :notice => "Comments are not allowed on this request" + end + end + + # Banned from adding comments? + def reject_if_user_banned + if authenticated_user && !authenticated_user.can_make_comments? + @details = authenticated_user.can_fail_html + render :template => 'user/banned' + end + end + +end diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index a94461758..6445dd685 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -447,9 +447,9 @@ class RequestController < ApplicationController flash[:notice] = case info_request.calculate_status when 'waiting_response' _("<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get a response promptly, and normally before the end of <strong> -{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>simple_date(info_request.date_response_required_by)) +{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>view_context.simple_date(info_request.date_response_required_by)) when 'waiting_response_overdue' - _("<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response promptly, and normally before the end of <strong>{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>simple_date(info_request.date_response_required_by)) + _("<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response promptly, and normally before the end of <strong>{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>view_context.simple_date(info_request.date_response_required_by)) when 'waiting_response_very_overdue' _("<p>Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.</p>", :very_late_number_of_days => AlaveteliConfiguration::reply_very_late_after_days, :late_number_of_days => AlaveteliConfiguration::reply_late_after_days) when 'not_held' diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 78c494dba..97c47c448 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -17,8 +17,15 @@ class ServicesController < ApplicationController text = _("Hello! You can make Freedom of Information requests within {{country_name}} at {{link_to_website}}", :country_name => found_country[:country_name], :link_to_website => "<a href=\"#{found_country[:url]}\">#{found_country[:name]}</a>".html_safe) else - current_country = WorldFOIWebsites.by_code(iso_country_code)[:country_name] - text = _("Hello! We have an <a href=\"/help/alaveteli?country_name=#{CGI.escape(current_country)}\">important message</a> for visitors outside {{country_name}}", :country_name => current_country) + country_data = WorldFOIWebsites.by_code(iso_country_code) + if country_data + text = _("Hello! We have an <a href=\"{{url}}\">important message</a> for visitors outside {{country_name}}", + :country_name => country_data[:country_name], + :url => "/help/alaveteli?country_name=#{CGI.escape(country_data[:country_name])}") + else + text = _("Hello! We have an <a href=\"{{url}}\">important message</a> for visitors in other countries", + :url => "/help/alaveteli") + end end ensure FastGettext.locale = old_fgt_locale diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 5115abc52..594296e77 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -279,13 +279,58 @@ module LinkToHelper end end - # Basic date format - def simple_date(date) + # Public: Usually-correct format for a DateTime-ish object + # To define a new new format define the `simple_date_{FORMAT}` method + # + # date - a DateTime, Date or Time + # opts - a Hash of options (default: { format: :html}) + # :format - :html returns a HTML <time> tag + # :text returns a plain String + # + # Examples + # + # simple_date(Time.now) + # # => "<time>..." + # + # simple_date(Time.now, :format => :text) + # # => "March 10, 2014" + # + # Returns a String + # Raises ArgumentError if the format is unrecognized + def simple_date(date, opts = {}) + opts = { :format => :html }.merge(opts) + date_formatter = "simple_date_#{ opts[:format] }" + + if respond_to?(date_formatter) + send(date_formatter, date) + else + raise ArgumentError, "Unrecognised format :#{ opts[:format] }" + end + end + + # Usually-correct HTML formatting of a DateTime-ish object + # Use LinkToHelper#simple_date with desired formatting options + # + # date - a DateTime, Date or Time + # + # Returns a String + def simple_date_html(date) + date = date.in_time_zone unless date.is_a? Date + time_tag date, simple_date_text(date), :title => date.to_s + end + + # Usually-correct plain text formatting of a DateTime-ish object + # Use LinkToHelper#simple_date with desired formatting options + # + # date - a DateTime, Date or Time + # + # Returns a String + def simple_date_text(date) date = date.in_time_zone.to_date unless date.is_a? Date date_format = _("simple_date_format") date_format = :long if date_format == "simple_date_format" - return I18n.l(date, :format => date_format) + I18n.l(date, :format => date_format) end def simple_time(date) diff --git a/app/views/admin_request/show.html.erb b/app/views/admin_request/show.html.erb index 2589e52b4..9c04badeb 100644 --- a/app/views/admin_request/show.html.erb +++ b/app/views/admin_request/show.html.erb @@ -118,7 +118,7 @@ </label> <div class="controls"> <%= link_to 'Generate URL', admin_request_generate_upload_url_path(@info_request), :class => "btn" %> - <p class="help-block">(see also option to general URLs for individual incoming messages below)</p> + <p class="help-block">(see also option to generate URLs for individual incoming messages below)</p> </div> </div> <%= form_tag admin_request_hide_path(@info_request), :class => "form form-inline", :id => "hide_request_form", 'data-info-request-id' => @info_request.id.to_s do %> diff --git a/app/views/comment/_single_comment.text.erb b/app/views/comment/_single_comment.text.erb index 925e8b688..4932a7e4a 100644 --- a/app/views/comment/_single_comment.text.erb +++ b/app/views/comment/_single_comment.text.erb @@ -1,2 +1,2 @@ -<%= _("{{username}} left an annotation:", :username =>comment.user.name) %> (<%= simple_date(comment.created_at || Time.now) %>) +<%= _("{{username}} left an annotation:", :username =>comment.user.name) %> (<%= simple_date((comment.created_at || Time.now), :format => :text) %>) <%= comment.body.strip %> diff --git a/app/views/request/_outgoing_correspondence.text.erb b/app/views/request/_outgoing_correspondence.text.erb index 5375ef81b..221e359e2 100644 --- a/app/views/request/_outgoing_correspondence.text.erb +++ b/app/views/request/_outgoing_correspondence.text.erb @@ -3,6 +3,6 @@ <%- else %> <%= _('From:') %> <% if @info_request.user_name %><%= @info_request.user_name %><% else %><%= "[#{_('An anonymous user')}]"%><% end %> <%= _('To:') %> <%= @info_request.public_body.name %> - <%= _('Date:') %> <%= simple_date(info_request_event.created_at) %> + <%= _('Date:') %> <%= simple_date(info_request_event.created_at, :format => :text) %> <%= outgoing_message.get_body_for_text_display %> <%- end %> diff --git a/app/views/request/_resent_outgoing_correspondence.text.erb b/app/views/request/_resent_outgoing_correspondence.text.erb index d645e9488..d39f8395b 100644 --- a/app/views/request/_resent_outgoing_correspondence.text.erb +++ b/app/views/request/_resent_outgoing_correspondence.text.erb @@ -1,2 +1,2 @@ -<%= _('Date:') %> <%= simple_date(info_request_event.created_at) %> +<%= _('Date:') %> <%= simple_date(info_request_event.created_at, :format => :text) %> Sent <% if outgoing_message.message_type == 'initial_request' %> request <% elsif outgoing_message.message_type == 'followup' %> a follow up <% else %> <% raise "unknown message_type" %><% end %> to <%= public_body_link(@info_request.public_body) %> again<% if not info_request_event.same_email_as_previous_send? %>, using a new contact address<% end %>. diff --git a/app/views/track_mailer/event_digest.text.erb b/app/views/track_mailer/event_digest.text.erb index 8dbc7fe06..b83c184f0 100644 --- a/app/views/track_mailer/event_digest.text.erb +++ b/app/views/track_mailer/event_digest.text.erb @@ -32,7 +32,7 @@ else raise "unknown type in event_digest " + event.event_type end - main_text += " (" + simple_date(event.created_at) + ")\n" + main_text += " (" + simple_date(event.created_at, :format => :text) + ")\n" # Main text, wrapped, words highlighted with * and indented. if event.is_outgoing_message? diff --git a/config/Vagrantfile b/config/Vagrantfile deleted file mode 100644 index 4253215fc..000000000 --- a/config/Vagrantfile +++ /dev/null @@ -1,23 +0,0 @@ -# This Vagrantfile should be used with the --no-color option, e.g. -# vagrant --no-color up -# Then you should be able to visit the site at: -# http://alaveteli.10.10.10.30.xip.io - -Vagrant::Config.run do |config| - config.vm.box = "precise64" - config.vm.box_url = "http://files.vagrantup.com/precise64.box" - config.vm.network :hostonly, "10.10.10.30" - # The bundle install fails unless you have quite a large amount of - # memory; insist on 1.5GiB: - config.vm.customize ["modifyvm", :id, "--memory", 1536] - # Fetch and run the install script: - config.vm.provision :shell, :inline => "wget -O install-site.sh https://raw.github.com/mysociety/commonlib/master/bin/install-site.sh" - config.vm.provision :shell, :inline => "chmod a+rx install-site.sh" - # This is only needed before the install-script branch is merged to - # master: - config.vm.provision :shell, :inline => "sed -i -e 's/BRANCH=master/BRANCH=install-script/' install-site.sh" - config.vm.provision :shell, :inline => "./install-site.sh " \ - "alaveteli " \ - "alaveteli " \ - "alaveteli.10.10.10.30.xip.io" -end diff --git a/config/general.yml-example b/config/general.yml-example index 47946b7d3..ec9bdb6b5 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -172,11 +172,6 @@ VARNISH_HOST: localhost # Adding a value here will enable Google Analytics on all non-admin pages for non-admin users. GA_CODE: '' -# We need to add the WDTK survey variables here, or else the deployment -# system will cry. -SURVEY_SECRET: '' -SURVEY_URL: '' - # If you want to override *all* the public body request emails with your own # email so that request emails that would normally go to the public body # go to you, then uncomment below and fill in your email. @@ -220,6 +215,10 @@ USE_MAILCATCHER_IN_DEVELOPMENT: true # config.action_controller.perform_caching is set to true CACHE_FRAGMENTS: true +# The default bundle path is vendor/bundle; you can set this option to +# change it. +BUNDLE_PATH: vendor/bundle + # In some deployments of Alaveteli you may wish to install each newly # deployed version alongside the previous ones, in which case certain # files and resources should be shared between these installations: diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb index 6df1823a5..c7672d05b 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.16' +ALAVETELI_VERSION = '0.17' # Add new inflection rules using the following format # (all these examples are active by default): diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 70571dbfa..8940cd78b 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -1,18 +1,49 @@ -# rails-3-develop +# Version 0.17 ## Highlighted features +* There is some initial support for making a request to multiple + authorities at once. * There is a new form for users to request that a new authority should be added, or to request an update to the contact email used for an authority. Site admins are emailed about these requests, and can resolve them from the admin interface. +* For attachments where we rely on Google Document Viewer to display the + HTML version, link to the HTTPS version where the Alaveteli site is + served over HTTPS to avoid mixed content warnings and non display in + some browsers (Matthew Somerville). +* The 'view requests' page now has some fragment caching backed by + memcached to speed up serving commonly used lists of requests - e.g + all successful requests. Like the caching introduced in release 0.16, + this is controlled by the `CACHE_FRAGMENTS` parameter in the config + file and will be on by default. +* A user's annotations can now be seen on their admin page (Andrew + Black) +* Better detection of the quoted text of a previous email in the HTML + parts of responses. +* Fixed bugs in the profile photos (György Peng), calendar translations + (Mark Longair), the use of external utilities (Ian Chard), the + internal admin authority locale handling (Mark Longair), badly formed + attachment handling (Rowan Crawford). ## Upgrade notes +* To use the batch request functionality, set the `ALLOW_BATCH_REQUESTS` + parameter to `true` in your config file. Once this is done, and the + install has been restarted, any user for whom 'Can make batch + requests' is checked in the admin interface should see a new link on + the 'Select an authority' page that allows them to make a batch + request. * If your theme overrides the help/requesting template, you should update the link in the section on requesting new authorities so the link points to `<%= new_change_request_path %>` instead of `<%= help_contact_path %>`. +* If your site runs over HTTPS, some cached attachments may still + contain links to Google Document Viewer with 'http', not 'https'. You + can clear the cached attachments after upgrade, and they will be + created with links that use the correct protocol. +* This release includes an update to the commonlib submodule - you + should be warned about this when running rails-post-deploy. # Version 0.16 diff --git a/lib/normalize_string.rb b/lib/normalize_string.rb index f02b18ee0..3b6116970 100644 --- a/lib/normalize_string.rb +++ b/lib/normalize_string.rb @@ -1,4 +1,4 @@ -require 'iconv' unless RUBY_VERSION.to_f >= 1.9 +require 'iconv' unless String.method_defined?(:encode) require 'charlock_holmes' class EncodingNormalizationError < StandardError @@ -23,17 +23,16 @@ def normalize_string_to_utf8(s, suggested_character_encoding=nil) to_try.push guessed_encoding to_try.each do |from_encoding| - if RUBY_VERSION.to_f >= 1.9 + if String.method_defined?(:encode) begin s.force_encoding from_encoding return s.encode('UTF-8') if s.valid_encoding? - rescue ArgumentError + rescue ArgumentError, Encoding::UndefinedConversionError # We get this is there are invalid bytes when # interpreted as from_encoding at the point of # the encode('UTF-8'); move onto the next one... end else - to_encoding = 'UTF-8' begin converted = Iconv.conv 'UTF-8', from_encoding, s return converted @@ -45,7 +44,6 @@ def normalize_string_to_utf8(s, suggested_character_encoding=nil) end end raise EncodingNormalizationError, "Couldn't find a valid character encoding for the string" - end def convert_string_to_utf8_or_binary(s, suggested_character_encoding=nil) @@ -69,13 +67,13 @@ def convert_string_to_utf8_or_binary(s, suggested_character_encoding=nil) result = normalize_string_to_utf8 s, suggested_character_encoding rescue EncodingNormalizationError result = s - s.force_encoding 'ASCII-8BIT' if RUBY_VERSION.to_f >= 1.9 + s.force_encoding 'ASCII-8BIT' if String.method_defined?(:encode) end result end def log_text_details(message, text) - if RUBY_VERSION.to_f >= 1.9 + if String.method_defined?(:encode) STDERR.puts "#{message}, we have text: #{text}, of class #{text.class} and encoding #{text.encoding}" else STDERR.puts "#{message}, we have text: #{text}, of class #{text.class}" diff --git a/locale/bg/app.po b/locale/bg/app.po index 741400bd1..ab743bbf7 100644 --- a/locale/bg/app.po +++ b/locale/bg/app.po @@ -5,14 +5,15 @@ # Translators: # antitoxic <antitoxic@gmail.com>, 2013 # antitoxic <antitoxic@gmail.com>, 2013 +# louisecrow <louise@mysociety.org>, 2014 # Valentin Laskov <laskov@festa.bg>, 2013-2014 msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-02-27 09:52+0000\n" -"PO-Revision-Date: 2014-02-27 09:59+0000\n" -"Last-Translator: louisecrow <louise@mysociety.org>\n" +"PO-Revision-Date: 2014-03-01 08:10+0000\n" +"Last-Translator: Valentin Laskov <laskov@festa.bg>\n" "Language-Team: Bulgarian (http://www.transifex.com/projects/p/alaveteli/language/bg/)\n" "Language: bg\n" "MIME-Version: 1.0\n" @@ -549,7 +550,7 @@ msgid "Change your password {{site_name}}" msgstr "Промяна на паролата Ви {{site_name}}" msgid "Charity registration" -msgstr "" +msgstr "Регистрация на фондацията" msgid "Check for mistakes if you typed or copied the address." msgstr "Проверете за грешки ако сте написали или копирали адреса." @@ -570,7 +571,7 @@ msgid "Clarify your FOI request - " msgstr "Пояснете Вашето Заявление за ДдИ - " msgid "Classify an FOI response from " -msgstr "" +msgstr "Класифициране на отговор за ДдИ от " msgid "Clear photo" msgstr "Премахни снимката" @@ -1355,10 +1356,10 @@ msgid "Make a batch request" msgstr "Направете размножено заявление" msgid "Make a new EIR request" -msgstr "" +msgstr "Ново заявление за околната среда" msgid "Make a new FOI request" -msgstr "" +msgstr "Ново заявление за ДдИ" msgid "Make a new<br/>\\n <strong>Freedom <span>of</span><br/>\\n Information<br/>\\n request</strong>" msgstr "Създаване на ново<br/>\\n <strong>Заявление <span>за</span><br/>\\n Достъп до<br/>\\n Информация</strong>" @@ -1481,7 +1482,7 @@ msgid "No similar requests found." msgstr "Няма намерени подобни резултати." msgid "No tracked things found." -msgstr "" +msgstr "Не са намерени следени неща." msgid "Nobody has made any Freedom of Information requests to {{public_body_name}} using this site yet." msgstr "До {{public_body_name}} все още никой не е отправил заявление за Достъп до информация чрез този сайт." @@ -2630,7 +2631,7 @@ msgid "This authority no longer exists, so you cannot make a request to it." msgstr "Този орган вече не съществува, поради което не може да отправите заявление към него." msgid "This covers a very wide spectrum of information about the state of\\n the <strong>natural and built environment</strong>, such as:" -msgstr "" +msgstr "Това покрива широк спектър информация относно състоянието\\n на <strong>природната среда и строителството</strong>, като:" msgid "This external request has been hidden" msgstr "Външното заявление беше скрито" @@ -3399,10 +3400,10 @@ msgid "[FOI #{{request}} email]" msgstr "[ДдИ #{{request}} имейл]" msgid "[{{public_body}} request email]" -msgstr "" +msgstr "[{{public_body}} имейл за заявления]" msgid "[{{site_name}} contact email]" -msgstr "" +msgstr "[{{site_name}} имейл за контакти]" msgid "\\n\\n[ {{site_name}} note: The above text was badly encoded, and has had strange characters removed. ]" msgstr "\\n\\n[ {{site_name}} съобщение: Горният текст е в непозволен формат. Някои странни символи бяха премахнати. ]" @@ -3748,7 +3749,7 @@ msgid "{{title}} - a batch request" msgstr "{{title}} - размножено заявление" msgid "{{user_name}} (Account suspended)" -msgstr "" +msgstr "{{user_name}} (Блокирана регистрация)" msgid "{{user_name}} - Freedom of Information requests" msgstr "{{user_name}} - Заявления за Достъп до Обществена Информация" diff --git a/locale/cy/app.po b/locale/cy/app.po index 12ae31701..f6b48c94d 100644 --- a/locale/cy/app.po +++ b/locale/cy/app.po @@ -21,7 +21,6 @@ msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-02-27 09:52+0000\n" -"PO-Revision-Date: 2014-02-27 09:59+0000\n" "Last-Translator: louisecrow <louise@mysociety.org>\n" "Language-Team: Welsh (http://www.transifex.com/projects/p/alaveteli/language/cy/)\n" "Language: cy\n" diff --git a/locale/en_UG/app.po b/locale/en_UG/app.po index c584a6bd9..4a553743a 100644 --- a/locale/en_UG/app.po +++ b/locale/en_UG/app.po @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: version 0.0.1\n" +"Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-02-27 09:52+0000\n" "PO-Revision-Date: 2014-01-31 09:14+0000\n" diff --git a/locale/he_IL/app.po b/locale/he_IL/app.po index 28b614c86..1458eb384 100644 --- a/locale/he_IL/app.po +++ b/locale/he_IL/app.po @@ -8,7 +8,7 @@ # Ram Ezrach <ram.ezrach@gmail.com>, 2013 # rshlo <r@roishlomi.com>, 2013 # rshlo <r@roishlomi.com>, 2013 -# yauzi <yair.uziel@gmail.com>, 2013 +# yauzi <yair.uziel@gmail.com>, 2013-2014 # yauzi <yair.uziel@gmail.com>, 2013 # yehuda <yehudab@gmail.com>, 2013 # yehuda <yehudab@gmail.com>, 2013 @@ -21,8 +21,8 @@ msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-02-27 09:52+0000\n" -"PO-Revision-Date: 2014-02-27 09:59+0000\n" -"Last-Translator: louisecrow <louise@mysociety.org>\n" +"PO-Revision-Date: 2014-03-03 17:37+0000\n" +"Last-Translator: yauzi <yair.uziel@gmail.com>\n" "Language-Team: Hebrew (Israel) (http://www.transifex.com/projects/p/alaveteli/language/he_IL/)\n" "Language: he_IL\n" "MIME-Version: 1.0\n" @@ -693,7 +693,10 @@ msgid "Dear {{name}}," msgstr "{{name}} יקר," msgid "Dear {{public_body_name}}," -msgstr "{{public_body_name}} נכבד, " +msgstr "" +"לכבוד הממונה על חוק חופש המידע ב{{public_body_name}},\n" +"\n" +"בהתאם לסעיף 7 לחוק חופש המידע, התשנ\"ח-1998 הריני לפנות אליכם כדלקמן:" msgid "Dear {{user_name}}," msgstr "" @@ -3398,10 +3401,10 @@ msgid "Your {{site_name}} email alert" msgstr "התרעת הדוא\"ל שלכם מאתר {{site_name}} " msgid "Yours faithfully," -msgstr "שלכם במסירות," +msgstr "בתודה מראש על טיפולכם המסור בבקשה זו," msgid "Yours sincerely," -msgstr "שלכם בכנות," +msgstr "בתודה מראש על טיפולכם המסור בבקשה זו," msgid "Yours," msgstr "בהוקרה," diff --git a/script/install-as-user b/script/install-as-user index aaad52145..a6c267066 100755 --- a/script/install-as-user +++ b/script/install-as-user @@ -114,6 +114,7 @@ then -e "s,^( *DONATION_URL:).*,\\1 null," \ -e "s,^( *THEME_BRANCH:).*,\\1 'develop'," \ -e "s,^( *USE_MAILCATCHER_IN_DEVELOPMENT:).*,\\1 false," \ + -e "s,^( *BUNDLE_PATH:).*,\\1 $HOME/bundle/," \ config/general.yml-example > config/general.yml fi diff --git a/script/mailin b/script/mailin index f782df215..65f9d06f2 100755 --- a/script/mailin +++ b/script/mailin @@ -22,7 +22,8 @@ then # send error to administators (use mutt for MIME encoding) SUBJ="Mail import error for $OPTION_DOMAIN" BODY="There was an error code $ERROR_CODE returned by the RequestMailer.receive command in script/mailin. See attached for details. This might be quite serious, such as the database was down, or might be an email with corrupt headers that Rails is choking on. We returned the email with an exit code 75, which for Exim at least instructs the MTA to try again later. A well configured installation of this code will separately have had Exim make a backup copy of the email in a separate mailbox, just in case." - /usr/bin/mutt -s "$SUBJ" -a "$OUTPUT" "$INPUT" -- "$OPTION_CONTACT_EMAIL" <<<"$BODY" + FROM="$OPTION_BLACKHOLE_PREFIX@$OPTION_INCOMING_EMAIL_DOMAIN" + /usr/bin/mutt -e "set use_envelope_from" -e "set envelope_from_address=$FROM" -s "$SUBJ" -a "$OUTPUT" "$INPUT" -- "$OPTION_FORWARD_NONBOUNCE_RESPONSES_TO" <<<"$BODY" # tell exim error was temporary, so try again later (no point bouncing message to authority) rm -f "$INPUT" "$OUTPUT" diff --git a/script/rails-deploy-before-down b/script/rails-deploy-before-down index ad1049e44..c157a8624 100755 --- a/script/rails-deploy-before-down +++ b/script/rails-deploy-before-down @@ -123,19 +123,24 @@ END echo "ENV['RAILS_ENV'] ||= 'production'" > config/rails_env.rb fi -bundle_install_options="" +BUNDLE_PATH="${OPTION_BUNDLE_PATH:-vendor/bundle}" + +bundle_install_options="--path $BUNDLE_PATH" + if [ "$OPTION_STAGING_SITE" = "0" ] then - bundle_install_options="--without development:test --deployment" + bundle_install_options="$bundle_install_options --without development:test --deployment" fi if [ "$OPTION_STAGING_SITE" = "1" ] then - bundle_install_options="--path vendor/bundle" + bundle_install_options="$bundle_install_options" fi if [ "$TRAVIS" = "true" ] then bundle_install_options="--without development develop --deployment" fi + +echo "Running bundle install with options: $bundle_install_options" bundle install $bundle_install_options bundle exec rake submodules:check diff --git a/spec/controllers/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb index c03615ce2..5e250f689 100644 --- a/spec/controllers/comment_controller_spec.rb +++ b/spec/controllers/comment_controller_spec.rb @@ -53,16 +53,30 @@ describe CommentController, "when commenting on a request" do response.should render_template('new') end - + it "should not allow comments if comments are not allowed" do - session[:user_id] = users(:silly_name_user).id - - expect { - post :new, :url_title => info_requests(:spam_1_request).url_title, - :comment => { :body => "I demand to be heard!" }, - :type => 'request', :submitted_comment => 1, :preview => 0 - }.to raise_error("Comments are not allowed on this request") - + session[:user_id] = users(:silly_name_user).id + info_request = info_requests(:spam_1_request) + + post :new, :url_title => info_request.url_title, + :comment => { :body => "I demand to be heard!" }, + :type => 'request', :submitted_comment => 1, :preview => 0 + + response.should redirect_to(show_request_path(info_request.url_title)) + flash[:notice].should == 'Comments are not allowed on this request' + end + + it "should not allow comments from banned users" do + User.any_instance.stub(:ban_text).and_return('Banned from commenting') + + user = users(:silly_name_user) + session[:user_id] = user.id + + post :new, :url_title => info_requests(:fancy_dog_request).url_title, + :comment => { :body => comments(:silly_comment).body }, + :type => 'request', :submitted_comment => 1, :preview => 0 + + response.should render_template('user/banned') end describe 'when commenting on an external request' do diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index 2259db6c2..4a01ec683 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -70,14 +70,50 @@ describe LinkToHelper do end describe 'simple_date' do + + it 'formats a date in html by default' do + time = Time.utc(2012, 11, 07, 21, 30, 26) + self.should_receive(:simple_date_html).with(time) + simple_date(time) + end + + it 'formats a date in the specified format' do + time = Time.utc(2012, 11, 07, 21, 30, 26) + self.should_receive(:simple_date_text).with(time) + simple_date(time, :format => :text) + end + + it 'raises an argument error if given an unrecognized format' do + time = Time.utc(2012, 11, 07, 21, 30, 26) + expect { simple_date(time, :format => :unknown) }.to raise_error(ArgumentError) + end + + end + + describe 'simple_date_html' do + + it 'formats a date in a time tag' do + Time.use_zone('London') do + time = Time.utc(2012, 11, 07, 21, 30, 26) + expected = "<time datetime=\"2012-11-07T21:30:26+00:00\" title=\"2012-11-07 21:30:26 +0000\">November 07, 2012</time>" + simple_date_html(time).should == expected + end + end + + end + + describe 'simple_date_text' do + it 'should respect time zones' do Time.use_zone('Australia/Sydney') do - simple_date(Time.utc(2012, 11, 07, 21, 30, 26)).should == 'November 08, 2012' + simple_date_text(Time.utc(2012, 11, 07, 21, 30, 26)).should == 'November 08, 2012' end end it 'should handle Date objects' do - simple_date(Date.new(2012, 11, 21)).should == 'November 21, 2012' + simple_date_text(Date.new(2012, 11, 21)).should == 'November 21, 2012' end + end + end diff --git a/spec/lib/alaveteli_external_command.rb b/spec/lib/alaveteli_external_command_spec.rb index 18afeda33..18afeda33 100644 --- a/spec/lib/alaveteli_external_command.rb +++ b/spec/lib/alaveteli_external_command_spec.rb diff --git a/spec/lib/basic_encoding_tests.rb b/spec/lib/basic_encoding_spec.rb index 35d35fd4a..43a65eab9 100644 --- a/spec/lib/basic_encoding_tests.rb +++ b/spec/lib/basic_encoding_spec.rb @@ -4,8 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') def bytes_to_binary_string( bytes, claimed_encoding = nil ) claimed_encoding ||= 'ASCII-8BIT' bytes_string = bytes.pack('c*') - if RUBY_VERSION.to_f >= 1.9 - bytes_string.force_encoding! claimed_encoding + if String.method_defined?(:force_encoding) + bytes_string.force_encoding claimed_encoding end bytes_string end @@ -110,15 +110,15 @@ describe "convert_string_to_utf8_or_binary" do converted = convert_string_to_utf8_or_binary random_string converted.should == random_string - if RUBY_VERSION.to_f >= 1.9 - converted.encoding.should == 'ASCII-8BIT' + if String.method_defined?(:encode) + converted.encoding.to_s.should == 'ASCII-8BIT' end converted = convert_string_to_utf8_or_binary random_string,'UTF-8' converted.should == random_string - if RUBY_VERSION.to_f >= 1.9 - converted.encoding.should == 'ASCII-8BIT' + if String.method_defined?(:encode) + converted.encoding.to_s.should == 'ASCII-8BIT' end end @@ -132,8 +132,8 @@ describe "convert_string_to_utf8_or_binary" do converted.should == "DASH – DASH" - if RUBY_VERSION.to_f >= 1.9 - converted.encoding.should == 'UTF-8' + if String.method_defined?(:encode) + converted.encoding.to_s.should == 'UTF-8' end end @@ -147,8 +147,8 @@ describe "convert_string_to_utf8_or_binary" do converted.should start_with("贵公司负责人") - if RUBY_VERSION.to_f >= 1.9 - converted.encoding.should == 'UTF-8' + if String.method_defined?(:encode) + converted.encoding.to_s.should == 'UTF-8' end end diff --git a/spec/lib/confidence_intervals.rb b/spec/lib/confidence_intervals_spec.rb index cb8717f3d..cb8717f3d 100644 --- a/spec/lib/confidence_intervals.rb +++ b/spec/lib/confidence_intervals_spec.rb diff --git a/spec/lib/i18n_interpolation.rb b/spec/lib/i18n_interpolation_spec.rb index b07cf1e9a..47037ecdb 100644 --- a/spec/lib/i18n_interpolation.rb +++ b/spec/lib/i18n_interpolation_spec.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "when using i18n" do diff --git a/spec/mailers/info_request_batch_mailer.rb b/spec/mailers/info_request_batch_mailer_spec.rb index 19791e163..19791e163 100644 --- a/spec/mailers/info_request_batch_mailer.rb +++ b/spec/mailers/info_request_batch_mailer_spec.rb |