diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/about_me_validator.rb | 2 | ||||
-rw-r--r-- | app/models/censor_rule.rb | 8 | ||||
-rw-r--r-- | app/models/change_email_validator.rb | 9 | ||||
-rw-r--r-- | app/models/comment.rb | 7 | ||||
-rw-r--r-- | app/models/exim_log.rb | 6 | ||||
-rw-r--r-- | app/models/foi_attachment.rb | 28 | ||||
-rw-r--r-- | app/models/holiday.rb | 6 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 18 | ||||
-rw-r--r-- | app/models/info_request.rb | 14 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 15 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 6 | ||||
-rw-r--r-- | app/models/post_redirect.rb | 8 | ||||
-rw-r--r-- | app/models/profile_photo.rb | 6 | ||||
-rw-r--r-- | app/models/raw_email.rb | 7 | ||||
-rw-r--r-- | app/models/track_thing.rb | 12 | ||||
-rw-r--r-- | app/models/track_things_sent_email.rb | 12 | ||||
-rw-r--r-- | app/models/user.rb | 7 | ||||
-rw-r--r-- | app/models/user_info_request_sent_alert.rb | 4 |
18 files changed, 100 insertions, 75 deletions
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..a14e0b553 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 @@ -47,7 +63,13 @@ class FoiAttachment < ActiveRecord::Base 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 +324,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..f0f1680eb 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. 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: |