diff options
Diffstat (limited to 'app')
39 files changed, 241 insertions, 178 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index e249cef11..0c24d47c1 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -31,8 +31,8 @@ class AdminPublicBodyController < AdminController lower(public_body_translations.short_name) like lower('%'||?||'%') or lower(public_body_translations.request_email) like lower('%'||?||'%' )) AND (public_body_translations.locale = '#{@locale}')", @query, @query, @query], :joins => :translations - @public_bodies_by_tag = PublicBody::Translation.find_by_tag(@query) end + @public_bodies_by_tag = PublicBody.find_by_tag(@query) end def list diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b7457c48e..7aa522389 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,10 +11,15 @@ require 'open-uri' class ApplicationController < ActionController::Base + class PermissionDenied < StandardError + end # Standard headers, footers and navigation for whole site layout "default" include FastGettext::Translation # make functions like _, n_, N_ etc available) - + + # Send notification email on exceptions + include ExceptionNotification::Notifiable + # Note: a filter stops the chain if it redirects or renders something before_filter :authentication_check before_filter :set_gettext_locale @@ -117,8 +122,11 @@ class ApplicationController < ActionController::Base case exception when ActiveRecord::RecordNotFound, ActionController::UnknownAction, ActionController::RoutingError @status = 404 + when PermissionDenied + @status = 403 else @status = 500 + notify_about_exception exception end # Display user appropriate error message @exception_backtrace = exception.backtrace.join("\n") @@ -185,7 +193,7 @@ class ApplicationController < ActionController::Base return File.exists?(key_path) end def foi_fragment_cache_read(key_path) - cached = File.read(key_path) + return File.read(key_path) end def foi_fragment_cache_write(key_path, content) FileUtils.mkdir_p(File.dirname(key_path)) @@ -357,18 +365,39 @@ class ApplicationController < ActionController::Base def get_search_page_from_params return (params[:page] || "1").to_i end + def perform_search_typeahead(query, model) + # strip out unintended search operators - see + # https://github.com/sebbacon/alaveteli/issues/328 + # XXX this is a result of the OR hack below -- should fix by + # allowing a parameter to perform_search to control the + # default operator! + query = query.strip.gsub(/(\s-\s|&)/, "") + query = query.split(/ +(?![-+]+)/) + if query.last.nil? || query.last.strip.length < 3 + xapian_requests = nil + else + query = query.join(' OR ') # XXX: HACK for OR instead of default AND! + if model == PublicBody + collapse = nil + elsif model == InfoRequestEvent + collapse = 'request_collapse' + end + xapian_requests = perform_search([model], query, 'relevant', collapse, 5) + end + return xapian_requests + end # Store last visited pages, for contact form; but only for logged in users, as otherwise this breaks caching def set_last_request(info_request) if !session[:user_id].nil? - session[:last_request_id] = info_request.id - session[:last_body_id] = nil + cookies["last_request_id"] = info_request.id + cookies["last_body_id"] = nil end end def set_last_body(public_body) if !session[:user_id].nil? - session[:last_request_id] = nil - session[:last_body_id] = public_body.id + cookies["last_request_id"] = nil + cookies["last_body_id"] = public_body.id end end diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index c6d246b4c..9b00846ee 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -26,18 +26,18 @@ class HelpController < ApplicationController # if they clicked remove for link to request/body, remove it if params[:remove] @last_request = nil - session[:last_request_id] = nil - session[:last_body_id] = nil + cookies["last_request_id"] = nil + cookies["last_body_id"] = nil end # look up link to request/body - @last_request_id = session[:last_request_id].to_i + @last_request_id = cookies["last_request_id"].to_i if @last_request_id > 0 @last_request = InfoRequest.find(@last_request_id) else @last_request = nil end - @last_body_id = session[:last_body_id].to_i + @last_body_id = cookies["last_body_id"].to_i if @last_body_id > 0 @last_body = PublicBody.find(@last_body_id) else diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 62229a441..659433c9e 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -129,7 +129,7 @@ class PublicBodyController < ApplicationController end PublicBody.with_locale(@locale) do @public_bodies = PublicBody.paginate( - :order => "public_body_translations.name", :page => params[:page], :per_page => 1000, # fit all councils on one page + :order => "public_body_translations.name", :page => params[:page], :per_page => 100, :conditions => conditions, :joins => :translations ) @@ -185,14 +185,8 @@ class PublicBodyController < ApplicationController def search_typeahead # Since acts_as_xapian doesn't support the Partial match flag, we work around it # by making the last work a wildcard, which is quite the same - query = params[:q] - query = query.split(' ') - if query.last.nil? || query.last.strip.length < 3 - @xapian_requests = nil - else - query = query.join(' OR ') # XXX: HACK for OR instead of default AND! - @xapian_requests = perform_search([PublicBody], query, 'relevant', nil, 5) - end + query = params[:query] + @xapian_requests = perform_search_typeahead(query, PublicBody) render :partial => "public_body/search_ahead" end end diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 8672fdf75..99aa3c7ea 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -37,8 +37,7 @@ class RequestController < ApplicationController end if !params[:query].nil? query = params[:query] - query = query.split(' ').join(' OR ') # XXX: HACK for OR instead of default AND! - @xapian_requests = perform_search([PublicBody], query, 'relevant', nil, 5) + @xapian_requests = perform_search_typeahead(query, PublicBody) end medium_cache end @@ -118,11 +117,14 @@ class RequestController < ApplicationController def details long_cache @info_request = InfoRequest.find_by_url_title(params[:url_title]) - if !@info_request.user_can_view?(authenticated_user) - render :template => 'request/hidden', :status => 410 # gone - return + if @info_request.nil? + raise ActiveRecord::RecordNotFound.new("Request not found") + else + if !@info_request.user_can_view?(authenticated_user) + render :template => 'request/hidden', :status => 410 # gone + return + end end - @columns = ['id', 'event_type', 'created_at', 'described_state', 'last_described_at', 'calculated_state' ] end @@ -600,9 +602,13 @@ class RequestController < ApplicationController before_filter :authenticate_attachment, :only => [ :get_attachment, :get_attachment_as_html ] def authenticate_attachment # Test for hidden - incoming_message = IncomingMessage.find(params[:incoming_message_id]) - if !incoming_message.info_request.user_can_view?(authenticated_user) - render :template => 'request/hidden', :status => 410 # gone + if request.path =~ /\/$/ + raise PermissionDenied.new("Directory listing not allowed") + else + incoming_message = IncomingMessage.find(params[:incoming_message_id]) + if !incoming_message.info_request.user_can_view?(authenticated_user) + render :template => 'request/hidden', :status => 410 # gone + end end end @@ -755,13 +761,7 @@ class RequestController < ApplicationController # Since acts_as_xapian doesn't support the Partial match flag, we work around it # by making the last work a wildcard, which is quite the same query = params[:q] - query = query.split(' ') - if query.last.nil? || query.last.strip.length < 3 - @xapian_requests = nil - else - query = query.join(' OR ') # XXX: HACK for OR instead of default AND! - @xapian_requests = perform_search([InfoRequestEvent], query, 'relevant', 'request_collapse', 5) - end + @xapian_requests = perform_search_typeahead(query, InfoRequestEvent) render :partial => "request/search_ahead.rhtml" end @@ -814,7 +814,8 @@ class RequestController < ApplicationController for message in info_request.incoming_messages attachments = message.get_attachments_for_display for attachment in attachments - zipfile.get_output_stream(attachment.display_filename) { |f| + filename = "#{attachment.url_part_number}_#{attachment.display_filename}" + zipfile.get_output_stream(filename) { |f| f.puts(attachment.body) } end diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index e06701a5f..e39a0489d 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -46,7 +46,14 @@ class TrackController < ApplicationController # Track all updates to a particular public body def track_public_body - @public_body = PublicBody.find_by_url_name(params[:url_name]) + @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) + raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? + # If found by historic name, or alternate locale name, redirect to new name + if @public_body.url_name != params[:url_name] + redirect_to track_public_body_url(:url_name => @public_body.url_name, :feed => params[:feed]) + return + end + @track_thing = TrackThing.create_track_for_public_body(@public_body) return atom_feed_internal if params[:feed] == 'feed' diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index fc29a847c..45b71a3a9 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -116,8 +116,10 @@ class UserController < ApplicationController render :action => 'sign' return else - @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name] ? true : false) - if @user_signin.errors.size > 0 + if !@post_redirect.nil? + @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name] ? true : false) + end + if @post_redirect.nil? || @user_signin.errors.size > 0 # Failed to authenticate render :action => 'sign' return diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 5866c31f0..7903dee2a 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -189,10 +189,14 @@ module LinkToHelper url_prefix = "http://" + MySociety::Config.get("DOMAIN", '127.0.0.1:3000') url = url_prefix + relative_path if !append.nil? - env = Rack::MockRequest.env_for(url) - req = Rack::Request.new(env) - req.path_info += append - url = req.url + begin + env = Rack::MockRequest.env_for(url) + req = Rack::Request.new(env) + req.path_info += append + url = req.url + rescue URI::InvalidURIError + # don't append to it + end end return url end diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb index ec2b03201..e24c5512c 100644 --- a/app/models/about_me_validator.rb +++ b/app/models/about_me_validator.rb @@ -21,7 +21,7 @@ class AboutMeValidator < ActiveRecord::BaseWithoutTable def validate if !self.about_me.blank? && self.about_me.size > 500 - errors.add(_("Please keep it shorter than 500 characters")) + errors.add(:about_me, _("Please keep it shorter than 500 characters")) end end diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb index e2dc12d6f..201e60746 100644 --- a/app/models/censor_rule.rb +++ b/app/models/censor_rule.rb @@ -1,12 +1,12 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: censor_rules # # id :integer not null, primary key -# info_request_id :integer -# user_id :integer -# public_body_id :integer +# info_request_id :integer +# user_id :integer +# public_body_id :integer # text :text not null # replacement :text not null # last_edit_editor :string(255) not null diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb index f7ec6d17e..e3f8fa892 100644 --- a/app/models/change_email_validator.rb +++ b/app/models/change_email_validator.rb @@ -1,11 +1,12 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: change_email_validators # -# old_email :string -# new_email :string -# password :string +# old_email :string +# new_email :string +# password :string +# user_circumstance :string # # models/changeemail_validator.rb: diff --git a/app/models/comment.rb b/app/models/comment.rb index b7ece9ba9..44a1079cd 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,16 +1,17 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: comments # # id :integer not null, primary key # user_id :integer not null # comment_type :string(255) default("internal_error"), not null -# info_request_id :integer +# info_request_id :integer # body :text not null -# visible :boolean default(true), not null +# visible :boolean default(TRUE), not null # created_at :datetime not null # updated_at :datetime not null +# locale :text default(""), not null # # models/comments.rb: diff --git a/app/models/exim_log.rb b/app/models/exim_log.rb index 83f031a92..77e5e2d21 100644 --- a/app/models/exim_log.rb +++ b/app/models/exim_log.rb @@ -1,11 +1,11 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: exim_logs # # id :integer not null, primary key -# exim_log_done_id :integer -# info_request_id :integer +# exim_log_done_id :integer +# info_request_id :integer # order :integer not null # line :text not null # created_at :datetime not null diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index 057dcdb69..d12df688a 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -1,3 +1,19 @@ +# == Schema Information +# Schema version: 108 +# +# Table name: foi_attachments +# +# id :integer not null, primary key +# content_type :text +# filename :text +# charset :text +# display_size :text +# url_part_number :integer +# within_rfc822_subject :text +# incoming_message_id :integer +# hexdigest :string(32) +# + # encoding: UTF-8 # models/foi_attachment.rb: @@ -19,7 +35,7 @@ class FoiAttachment < ActiveRecord::Base before_destroy :delete_cached_file! def directory - base_dir = File.join("cache", "attachments_#{ENV['RAILS_ENV']}") + base_dir = File.join(File.dirname(__FILE__), "../../cache", "attachments_#{ENV['RAILS_ENV']}") return File.join(base_dir, self.hexdigest[0..2]) end @@ -41,13 +57,21 @@ class FoiAttachment < ActiveRecord::Base end File.open(self.filepath, "wb") { |file| file.write d + file.fsync } update_display_size! + @cached_body = d end def body if @cached_body.nil? - @cached_body = File.open(self.filepath, "rb" ).read + begin + @cached_body = File.open(self.filepath, "rb" ).read + rescue Errno::ENOENT + # we've lost our cached attachments for some reason. Reparse them. + force = true + self.incoming_message.parse_raw_email!(force) + end end return @cached_body end @@ -302,7 +326,7 @@ class FoiAttachment < ActiveRecord::Base body = $1.to_s body_without_tags = body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "") contains_images = html.match(/<img/mi) ? true : false - if !$?.success? || html.size == 0 || (body_without_tags.size == 0 && !contains_images) + if html.size == 0 || !$?.success? || (body_without_tags.size == 0 && !contains_images) ret = "<html><head></head><body>"; if self.has_google_docs_viewer? wrapper_id = "wrapper_google_embed" diff --git a/app/models/holiday.rb b/app/models/holiday.rb index 4674d58f1..60b5ff443 100644 --- a/app/models/holiday.rb +++ b/app/models/holiday.rb @@ -1,11 +1,11 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: holidays # # id :integer not null, primary key -# day :date -# description :text +# day :date +# description :text # # models/holiday.rb: diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 20989d641..2186d50dc 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -1,7 +1,5 @@ -# encoding: UTF-8 - # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: incoming_messages # @@ -10,11 +8,19 @@ # created_at :datetime not null # updated_at :datetime not null # raw_email_id :integer not null -# cached_attachment_text_clipped :text -# cached_main_body_text_folded :text -# cached_main_body_text_unfolded :text +# cached_attachment_text_clipped :text +# cached_main_body_text_folded :text +# cached_main_body_text_unfolded :text +# sent_at :time +# subject :text +# mail_from_domain :text +# valid_to_reply_to :boolean +# last_parsed :datetime +# mail_from :text # +# encoding: UTF-8 + # models/incoming_message.rb: # An (email) message from really anybody to be logged with a request. e.g. A # response from the public body. @@ -122,21 +128,23 @@ class IncomingMessage < ActiveRecord::Base # values in case we want to regenerate them (due to mail # parsing bugs, etc). if (!force.nil? || self.last_parsed.nil?) - self.extract_attachments! - self.sent_at = self.mail.date || self.created_at - self.subject = self.mail.subject - # XXX can probably remove from_name_if_present (which is a - # monkey patch) by just calling .from_addrs[0].name here - # instead? - self.mail_from = self.mail.from_name_if_present - begin - self.mail_from_domain = PublicBody.extract_domain_from_email(self.mail.from_addrs[0].spec) - rescue NoMethodError - self.mail_from_domain = "" + ActiveRecord::Base.transaction do + self.extract_attachments! + self.sent_at = self.mail.date || self.created_at + self.subject = self.mail.subject + # XXX can probably remove from_name_if_present (which is a + # monkey patch) by just calling .from_addrs[0].name here + # instead? + self.mail_from = self.mail.from_name_if_present + begin + self.mail_from_domain = PublicBody.extract_domain_from_email(self.mail.from_addrs[0].spec) + rescue NoMethodError + self.mail_from_domain = "" + end + self.valid_to_reply_to = self._calculate_valid_to_reply_to + self.last_parsed = Time.now + self.save! end - self.valid_to_reply_to = self._calculate_valid_to_reply_to - self.last_parsed = Time.now - self.save! end end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index cfef6ebd8..a0652ecd8 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -1,6 +1,5 @@ - # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: info_requests # @@ -11,20 +10,15 @@ # created_at :datetime not null # updated_at :datetime not null # described_state :string(255) not null -# awaiting_description :boolean default(false), not null +# awaiting_description :boolean default(FALSE), not null # prominence :string(255) default("normal"), not null # url_title :text not null # law_used :string(255) default("foi"), not null # allow_new_responses_from :string(255) default("anybody"), not null # handle_rejected_responses :string(255) default("bounce"), not null +# idhash :string(255) not null # -# models/info_request.rb: -# A Freedom of Information request. -# -# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. -# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: info_request.rb,v 1.217 2009-10-26 17:52:39 francis Exp $ + require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 4ea89bf81..8b7b9ebe4 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: info_request_events # @@ -8,12 +8,12 @@ # event_type :text not null # params_yaml :text not null # created_at :datetime not null -# described_state :string(255) -# calculated_state :string(255) -# last_described_at :datetime -# incoming_message_id :integer -# outgoing_message_id :integer -# comment_id :integer +# described_state :string(255) +# calculated_state :string(255) +# last_described_at :datetime +# incoming_message_id :integer +# outgoing_message_id :integer +# comment_id :integer # prominence :string(255) default("normal"), not null # @@ -147,6 +147,7 @@ class InfoRequestEvent < ActiveRecord::Base return event.calculated_state end end + return end def waiting_classification diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index b7e310b1e..cc561b21d 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: outgoing_messages # @@ -10,8 +10,8 @@ # message_type :string(255) not null # created_at :datetime not null # updated_at :datetime not null -# last_sent_at :datetime -# incoming_message_followup_id :integer +# last_sent_at :datetime +# incoming_message_followup_id :integer # what_doing :string(255) not null # diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index b111d019d..59cc86799 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -1,17 +1,17 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: post_redirects # # id :integer not null, primary key # token :text not null # uri :text not null -# post_params_yaml :text +# post_params_yaml :text # created_at :datetime not null # updated_at :datetime not null # email_token :text not null -# reason_params_yaml :text -# user_id :integer +# reason_params_yaml :text +# user_id :integer # circumstance :text default("normal"), not null # diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb index b15e3e4f4..43dbbbf0a 100644 --- a/app/models/profile_photo.rb +++ b/app/models/profile_photo.rb @@ -1,12 +1,12 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: profile_photos # # id :integer not null, primary key # data :binary not null -# user_id :integer -# draft :boolean default(false), not null +# user_id :integer +# draft :boolean default(FALSE), not null # # models/profile_photo.rb: diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb index c6066cbf4..c6f84318b 100644 --- a/app/models/raw_email.rb +++ b/app/models/raw_email.rb @@ -1,11 +1,10 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: raw_emails # -# id :integer not null, primary key -# data_text :text -# data_binary :binary +# id :integer not null, primary key +# # models/raw_email.rb: # The fat part of models/incoming_message.rb diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index b74f7dad5..6938fade9 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -1,18 +1,18 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: track_things # # id :integer not null, primary key # tracking_user_id :integer not null # track_query :string(255) not null -# info_request_id :integer -# tracked_user_id :integer -# public_body_id :integer +# info_request_id :integer +# tracked_user_id :integer +# public_body_id :integer # track_medium :string(255) not null # track_type :string(255) default("internal_error"), not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime +# updated_at :datetime # # models/track_thing.rb: diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb index d83bf05ff..777339d75 100644 --- a/app/models/track_things_sent_email.rb +++ b/app/models/track_things_sent_email.rb @@ -1,15 +1,15 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: track_things_sent_emails # # id :integer not null, primary key # track_thing_id :integer not null -# info_request_event_id :integer -# user_id :integer -# public_body_id :integer -# created_at :datetime -# updated_at :datetime +# info_request_event_id :integer +# user_id :integer +# public_body_id :integer +# created_at :datetime +# updated_at :datetime # # models/track_things_sent_email.rb: diff --git a/app/models/user.rb b/app/models/user.rb index e98d777b1..b6839aa31 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: users # @@ -10,13 +10,14 @@ # salt :string(255) not null # created_at :datetime not null # updated_at :datetime not null -# email_confirmed :boolean default(false), not null +# email_confirmed :boolean default(FALSE), not null # url_name :text not null # last_daily_track_email :datetime default(Sat Jan 01 00:00:00 UTC 2000) # admin_level :string(255) default("none"), not null # ban_text :text default(""), not null # about_me :text default(""), not null -# email_bounced_at :datetime +# locale :string(255) +# email_bounced_at :datetime # email_bounce_message :text default(""), not null # diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb index d07b4e553..5f23355bf 100644 --- a/app/models/user_info_request_sent_alert.rb +++ b/app/models/user_info_request_sent_alert.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 95 +# Schema version: 108 # # Table name: user_info_request_sent_alerts # @@ -7,7 +7,7 @@ # user_id :integer not null # info_request_id :integer not null # alert_type :string(255) not null -# info_request_event_id :integer +# info_request_event_id :integer # # models/user_info_request_sent_alert.rb: diff --git a/app/views/admin_general/debug.rhtml b/app/views/admin_general/debug.rhtml index 422edea03..b3b06085f 100644 --- a/app/views/admin_general/debug.rhtml +++ b/app/views/admin_general/debug.rhtml @@ -16,8 +16,6 @@ TMail::VERSION::STRING <%=h TMail::VERSION::STRING%> Xapian::version_string <%=h Xapian::version_string%> <br> Spec::VERSION::STRING <%=h Spec::VERSION::STRING%> -<br> -Spec::Rails::VERSION::STRING <%=h Spec::Rails::VERSION::STRING%> </p> <h2>Configuration</h2> diff --git a/app/views/admin_general/timeline.rhtml b/app/views/admin_general/timeline.rhtml index dc72e46cd..39a4b3e36 100644 --- a/app/views/admin_general/timeline.rhtml +++ b/app/views/admin_general/timeline.rhtml @@ -36,10 +36,9 @@ end %> <% elsif event.event_type == 'edit_outgoing' %> - <% outgoing_messages = OutgoingMessage.find(:all, event.params[:outgoing_message_id].to_i) %> + <% outgoing_message = OutgoingMessage.find(event.params[:outgoing_message_id].to_i) %> had outgoing message edited by administrator <strong><%=h event.params[:editor] %></strong>. - <% if outgoing_messages.size > 0 %> - <% outgoing_message = outgoing_messages[0] %> + <% if outgoing_message %> <% for p in ['body'] if event.params[p.to_sym] != event.params[('old_'+p).to_sym] %> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <% @@ -50,10 +49,9 @@ Missing outgoing message, internal error. <% end %> <% elsif event.event_type == 'edit_comment' %> - <% comments = Comment.find(:all, event.params[:comment_id].to_i) %> + <% comment = Comment.find(event.params[:comment_id].to_i) %> had annotation edited by administrator <strong><%=h event.params[:editor] %></strong>. - <% if comments.size > 0 %> - <% comment = comments[0] %> + <% if comment %> <% for p in ['body'] if event.params[p.to_sym] != event.params[('old_'+p).to_sym] %> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <% diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml index 1cdc9b3fe..d854b53f5 100644 --- a/app/views/admin_public_body/_form.rhtml +++ b/app/views/admin_public_body/_form.rhtml @@ -50,12 +50,13 @@ <h3>Common Fields</h3> <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> + +<%= text_field :public_body, :tag_string, :size => 60, :id => 'public_body_tag_string' %></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> +<%= text_field :public_body, :home_page, :size => 60, :id => 'public_body_home_page' %></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/> -<%= f.text_area :last_edit_comment, :rows => 3, :cols => 60 %></p> +<%= text_area :public_body, :last_edit_comment, :rows => 3, :cols => 60, :id => 'public_body_last_edit_comment' %></p> <!--[eoform:public_body]--> diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml index b91f15a2e..b19477a6b 100644 --- a/app/views/admin_public_body/edit.rhtml +++ b/app/views/admin_public_body/edit.rhtml @@ -9,9 +9,9 @@ <%= render :partial => 'tag_help' %> <div id="public_body_form"> - <% form_for @public_body, :url => {:action => 'update'} do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> - <p><%= f.submit 'Save', :accesskey => 's' %></p> + <% form_tag '../update/' + @public_body.id.to_s do %> + <%= render :partial => 'form' %> + <p><%= submit_tag 'Save', :accesskey => 's' %></p> <% end %> <p> diff --git a/app/views/general/_topnav.rhtml b/app/views/general/_topnav.rhtml index 619ff3593..8ef928bba 100644 --- a/app/views/general/_topnav.rhtml +++ b/app/views/general/_topnav.rhtml @@ -1,10 +1,10 @@ <div id="topnav"> <ul id="navigation"> - <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] != 'blog' %>"><%= link_to _("Home"), frontpage_url %></li> + <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] != 'blog' and params[:action] != 'search' %>"><%= link_to _("Home"), frontpage_url %></li> <li class="<%= 'selected' if params[:controller] == 'request' and ['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("Make a request"), select_authority_url, :id => 'make-request-link' %></li> <li class="<%= 'selected' if params[:controller] == 'request' and !['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("View requests"), request_list_successful_url %></li> <li class="<%= 'selected' if params[:controller] == 'public_body' %>"><%= link_to _("View authorities"), list_public_bodies_default %></li> <li class="<%= 'selected' if params[:controller] == 'general' and params[:action] == 'blog' %>"><%= link_to _("Read blog"), blog_url %></li> <li class="<%= 'selected' if params[:controller] == 'help' %>"><%= link_to _("Help"), help_about_url %></li> </ul> -</div>
\ No newline at end of file +</div> diff --git a/app/views/general/exception_caught.rhtml b/app/views/general/exception_caught.rhtml index b266b53a1..5f0dfe13d 100644 --- a/app/views/general/exception_caught.rhtml +++ b/app/views/general/exception_caught.rhtml @@ -19,6 +19,6 @@ <% end %> <h2><%= _('Technical details') %></h2> - <p><strong><%=@exception_class ? @exception_class : _("Unknown")%></strong></p> - <p><strong><%=@exception_message %></strong></p> + <p><strong><%= h(@exception_class ? @exception_class : _("Unknown")) %></strong></p> + <p><strong><%= h(@exception_message) %></strong></p> </div> diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index 35751b6a4..da45a8c37 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -60,7 +60,7 @@ <%= public_body_link(event.info_request.public_body) %> <%= _('answered a request about') %> <%=link_to h(event.info_request.title), request_url(event.info_request)%> <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %> - <p class="excerpt" onclick="document.location.href='<%=request_url(event.info_request)%>'"><%= excerpt(event.info_request.title, "", 200) %></p> + <p class="excerpt" onclick="document.location.href='<%=request_url(event.info_request)%>'"><%= excerpt(event.search_text_main(true), "", 200) %></p> </li> <% end %> </ul> diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml index 87a6ab446..43aa9785a 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.rhtml @@ -187,6 +187,8 @@ <%= render :partial => 'user/user_listing_single', :locals => { :display_user => result[:model] } %> <% end %> </div> + <%= will_paginate WillPaginate::Collection.new(@page, @users_per_page, @xapian_users.matches_estimated) %> + <% end %> </div> diff --git a/app/views/public_body/_search_ahead.rhtml b/app/views/public_body/_search_ahead.rhtml index 436471544..484d28256 100644 --- a/app/views/public_body/_search_ahead.rhtml +++ b/app/views/public_body/_search_ahead.rhtml @@ -13,6 +13,7 @@ <%= render :partial => 'body_listing_single', :locals => { :public_body => result[:model] } %> <% end %> </div> + <%= will_paginate WillPaginate::Collection.new(@page, 10, @xapian_requests.matches_estimated) %> <% end %> </p> diff --git a/app/views/request/_request_listing_via_event.rhtml b/app/views/request/_request_listing_via_event.rhtml index e7c378cec..e247163a3 100644 --- a/app/views/request/_request_listing_via_event.rhtml +++ b/app/views/request/_request_listing_via_event.rhtml @@ -4,7 +4,7 @@ end %> <div class="request_listing"> <div class="request_left"> - <span class="head"> + <span class="head"> <% if event.is_incoming_message? %> <%= link_to highlight_words(info_request.title, @highlight_words), incoming_message_url(event.incoming_message) %> <% elsif event.is_outgoing_message? and event.event_type == 'followup_sent' %> @@ -14,9 +14,9 @@ end %> <% else %> <%= link_to highlight_words(info_request.title, @highlight_words), request_url(info_request) %> <% end %> - </span> - <div class="requester"> - <% if event.event_type == 'sent' %> + </span> + <div class="requester"> + <% if event.event_type == 'sent' %> <%= _('Request sent to {{public_body_name}} by {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>user_link_absolute(info_request.user),:date=>simple_date(event.created_at )) %> <% elsif event.event_type == 'followup_sent' %> <%=event.display_status %> @@ -27,19 +27,22 @@ end %> <% elsif event.event_type == 'comment' %> <%= _('Request to {{public_body_name}} by {{info_request_user}}. Annotated by {{event_comment_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>user_link_absolute(info_request.user),:event_comment_user=>user_link_absolute(event.comment.user),:date=>simple_date(event.created_at)) %> <% else %> - <% raise _("unknown event type indexed ") + event.event_type %> + <%# Events of other types will not be indexed: see InfoRequestEvent#indexed_by_search? + However, it can happen that we see other types of event transiently here in the period + between a change being made and the update-xapian-index job being run. %> + <!-- Event of type '<%= event.event_type %>', id=<%= event.id %> --> <% end %> - </div> - <span class="bottomline icon_<%= info_request.calculate_status %>"> + </div> + <span class="bottomline icon_<%= info_request.calculate_status %>"> <strong> <%= info_request.display_status %> </strong><br> - </span> + </span> </div> <div class="request_right"> <span class="desc"> <%= highlight_and_excerpt(event.search_text_main(true), @highlight_words, 150) %> - </span> - </div> + </span> + </div> </div> diff --git a/app/views/request/select_authority.rhtml b/app/views/request/select_authority.rhtml index 55ebc40c4..0e8df872d 100644 --- a/app/views/request/select_authority.rhtml +++ b/app/views/request/select_authority.rhtml @@ -7,16 +7,17 @@ // http://benalman.com/projects/jquery-throttle-debounce-plugin/ $("#query").keypress($.debounce( 300, function() { // Do a type ahead search and display results - $("#typeahead_response").load("<%=search_ahead_bodies_url%>?q="+encodeURI(this.value), function() { + $("#typeahead_response").load("<%=search_ahead_bodies_url%>?query="+encodeURI(this.value), function() { $("#authority_preview").hide(); // Hide the preview, since results have changed }); })); // We're using the existing body list: we intercept the clicks on the titles to // display a preview on the right hand side of the screen - $("#typeahead_response a").live('click', function() { + $("#typeahead_response .head a").live('click', function() { $("#authority_preview").load(this.href+" #public_body_show", function() { $("#authority_preview").show(); + $(window).scrollTop($("#banner").height()); $("#authority_preview #header_right").hide(); }); return false; @@ -33,8 +34,8 @@ <p> <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 %> + like information from. <strong>By law, they have to respond</strong> + (<a href="%s#%s">why?</a>).') % [help_about_url, "whybother_them"] %> </p> <%= text_field_tag 'query', params[:query], { :size => 30 } %> <%= hidden_field_tag 'bodies', 1 %> @@ -56,6 +57,8 @@ <%= render :partial => 'public_body/body_listing_single', :locals => { :public_body => result[:model] } %> <% end %> </div> + <%= will_paginate WillPaginate::Collection.new(@page, 10, @xapian_requests.matches_estimated) %> + <% end %> diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml index 9ac203541..2d2394f5c 100644 --- a/app/views/user/show.rhtml +++ b/app/views/user/show.rhtml @@ -147,7 +147,7 @@ <% end %> <% else %> <h2 class="foi_results" id="foi_requests"> - <%= @is_you ? n_('Your %d Freedom of Information request', 'Your %d Freedom of Information requests', @xapian_requests.results.size) % @xapian_requests.results.size : n_('This person\'s %d Freedom of Information request', 'This person\'s %d Freedom of Information requests', @xapian_requests.results.size) % @xapian_requests.results.size %> + <%= @is_you ? n_('Your %d Freedom of Information request', 'Your %d Freedom of Information requests', @xapian_requests.results.size) % @xapian_requests.results.size : n_('This person\'s %d Freedom of Information request', 'This person\'s %d Freedom of Information requests', @xapian_requests.matches_estimated.to_s) % @xapian_requests.matches_estimated %> <!-- matches_estimated <%=@xapian_requests.matches_estimated%> --> <%= @match_phrase %> <%= @page_desc %> diff --git a/app/views/user/sign.rhtml b/app/views/user/sign.rhtml index afdb90162..bfd0fa63e 100644 --- a/app/views/user/sign.rhtml +++ b/app/views/user/sign.rhtml @@ -1,4 +1,4 @@ -<% if @post_redirect.reason_params[:user_name] %> +<% if !@post_redirect.nil? && @post_redirect.reason_params[:user_name] %> <% @title = _("Sign in") %> <div id="sign_alone"> @@ -19,16 +19,7 @@ <% else %> <% @title = _('Sign in or make a new account') %> - <div id="sign_together"> - - <!--<p id="sign_in_reason"> - <% if @post_redirect.reason_params[:web].empty? %> - <%= _(' Please sign in or make a new account.') %> - <% else %> - <%= @post_redirect.reason_params[:web] %>, <%= _('please sign in or make a new account.') %> - <% end %> - </p>--> - + <div id="sign_together"> <div id="left_half"> <h1><%= _('Sign in') %></h1> <%= render :partial => 'signin', :locals => { :sign_in_as_existing_user => false } %> |