diff options
-rw-r--r-- | app/controllers/admin_public_body_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 4 | ||||
-rw-r--r-- | app/views/admin_public_body/show.html.erb | 3 | ||||
-rw-r--r-- | app/views/contact_mailer/from_admin_message.text.erb | 1 | ||||
-rw-r--r-- | app/views/request/show.html.erb | 1 | ||||
-rw-r--r-- | config/general.yml-example | 5 | ||||
-rw-r--r-- | lib/mail_handler/backends/mail_extensions.rb | 5 | ||||
-rw-r--r-- | lib/tasks/temp.rake | 22 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/info_request_spec.rb | 28 |
10 files changed, 72 insertions, 5 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index 52b56eda2..078af12f4 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -75,6 +75,9 @@ class AdminPublicBodyController < AdminController @locale = self.locale_from_params() I18n.with_locale(@locale) do @public_body = PublicBody.find(params[:id]) + @info_requests = @public_body.info_requests.paginate :order => "created_at desc", + :page => params[:page], + :per_page => 100 render end end diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 74ea043bb..374866eda 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -131,7 +131,9 @@ class PublicBodyController < ApplicationController @public_bodies = PublicBody.where(conditions).joins(:translations).order("public_body_translations.name").paginate( :page => params[:page], :per_page => 100 ) - render :template => "public_body/list" + respond_to do |format| + format.html { render :template => "public_body/list" } + end end end diff --git a/app/views/admin_public_body/show.html.erb b/app/views/admin_public_body/show.html.erb index cfb10b24e..8262287d5 100644 --- a/app/views/admin_public_body/show.html.erb +++ b/app/views/admin_public_body/show.html.erb @@ -83,7 +83,8 @@ <% end %> <hr> <h2>Requests</h2> -<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @public_body.info_requests } %> +<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @info_requests } %> +<%= will_paginate(@info_requests, :class => "paginator") %> <hr> <h2>Track things</h2> <%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @public_body.track_things, :include_destroy => true } %> diff --git a/app/views/contact_mailer/from_admin_message.text.erb b/app/views/contact_mailer/from_admin_message.text.erb index 4169d8d3a..3af759c5d 100644 --- a/app/views/contact_mailer/from_admin_message.text.erb +++ b/app/views/contact_mailer/from_admin_message.text.erb @@ -1,2 +1 @@ <%= raw @message %> - diff --git a/app/views/request/show.html.erb b/app/views/request/show.html.erb index 4b0663f76..1d5b9977f 100644 --- a/app/views/request/show.html.erb +++ b/app/views/request/show.html.erb @@ -25,6 +25,7 @@ <div id="left_column"> <h1><%=h(@info_request.title)%></h1> + <% if !@info_request.is_external? && @info_request.user.profile_photo %> <p class="user_photo_on_request"> <img src="<%= get_profile_photo_url(:url_name => @info_request.user.url_name) %>" alt=""> diff --git a/config/general.yml-example b/config/general.yml-example index 17e1aa552..5e9e677bf 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -172,6 +172,11 @@ 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. diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb index 322c49bb5..6d6a20f8c 100644 --- a/lib/mail_handler/backends/mail_extensions.rb +++ b/lib/mail_handler/backends/mail_extensions.rb @@ -78,7 +78,10 @@ module Mail # invalid character at the end of the string, even # with UTF-8//IGNORE: # http://po-ru.com/diary/fixing-invalid-utf-8-in-ruby-revisited/ - str = Iconv.conv('UTF-8//IGNORE', fix_encoding(encoding), str + " ")[0...-4] + begin + str = Iconv.conv('UTF-8//IGNORE', fix_encoding(encoding), str + " ")[0...-4] + rescue Iconv::InvalidEncoding + end end str end diff --git a/lib/tasks/temp.rake b/lib/tasks/temp.rake index 35ae442c7..fcabb23de 100644 --- a/lib/tasks/temp.rake +++ b/lib/tasks/temp.rake @@ -7,6 +7,28 @@ namespace :temp do user.save! unless dryrun end + desc "Re-extract any missing cached attachments" + task :reextract_missing_attachments, [:commit] => :environment do |t, args| + dry_run = args.commit.nil? || args.commit.empty? + total_messages = 0 + messages_to_reparse = 0 + IncomingMessage.find_each :include => :foi_attachments do |im| + reparse = im.foi_attachments.any? { |fa| ! File.exists? fa.filepath } + total_messages += 1 + messages_to_reparse += 1 if reparse + if total_messages % 1000 == 0 + puts "Considered #{total_messages} received emails." + end + unless dry_run + im.parse_raw_email! true if reparse + sleep 2 + end + end + message = dry_run ? "Would reparse" : "Reparsed" + message += " #{messages_to_reparse} out of #{total_messages} received emails." + puts message + end + desc 'Cleanup accounts with a space in the email address' task :clean_up_emails_with_spaces => :environment do dryrun = ENV['DRYRUN'] == '0' ? false : true diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 22d8418c9..e01bcb0a6 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -183,8 +183,11 @@ describe PublicBodyController, "when listing bodies" do response.should render_template('list') assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ] assigns[:tag].should == "eats_cheese:stilton" + end - + it 'should return a "406 Not Acceptable" code if asked for a json version of a list' do + get :list, :format => 'json' + response.code.should == '406' end end diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 9b87f909e..db47bf8a9 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -454,6 +454,33 @@ describe InfoRequest do end + describe 'when an instance is asked if all can view it' do + + before do + @info_request = InfoRequest.new + end + + it 'should return true if its prominence is normal' do + @info_request.prominence = 'normal' + @info_request.all_can_view?.should == true + end + + it 'should return true if its prominence is backpage' do + @info_request.prominence = 'backpage' + @info_request.all_can_view?.should == true + end + + it 'should return false if its prominence is hidden' do + @info_request.prominence = 'hidden' + @info_request.all_can_view?.should == false + end + + it 'should return false if its prominence is requester_only' do + @info_request.prominence = 'requester_only' + @info_request.all_can_view?.should == false + end + end + describe 'when applying censor rules' do before do @@ -564,6 +591,7 @@ describe InfoRequest do end end + describe 'when working out a subject for a followup emails' do it "should not be confused by an nil subject in the incoming message" do |