diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/about_me_validator.rb | 2 | ||||
-rw-r--r-- | app/models/application_mailer.rb | 2 | ||||
-rw-r--r-- | app/models/change_email_validator.rb | 8 | ||||
-rw-r--r-- | app/models/comment.rb | 4 | ||||
-rw-r--r-- | app/models/contact_validator.rb | 2 | ||||
-rw-r--r-- | app/models/info_request.rb | 46 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 38 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 8 | ||||
-rw-r--r-- | app/models/public_body.rb | 40 | ||||
-rw-r--r-- | app/models/track_thing.rb | 16 | ||||
-rw-r--r-- | app/models/user.rb | 16 | ||||
-rw-r--r-- | app/models/user_mailer.rb | 4 |
12 files changed, 106 insertions, 80 deletions
diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb index f7b88f7dd..ec2b03201 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(:about_me, N_("Please keep it shorter than 500 characters")) + errors.add(_("Please keep it shorter than 500 characters")) end end diff --git a/app/models/application_mailer.rb b/app/models/application_mailer.rb index 8ee467b60..623b97c5b 100644 --- a/app/models/application_mailer.rb +++ b/app/models/application_mailer.rb @@ -15,7 +15,7 @@ class ApplicationMailer < ActionMailer::Base self.raise_delivery_errors = true def contact_from_name_and_email - "WhatDoTheyKnow <"+MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost')+">" + "InformataZyrtare <"+MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost')+">" end def blackhole_email diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb index 5cead4b4c..f7ec6d17e 100644 --- a/app/models/change_email_validator.rb +++ b/app/models/change_email_validator.rb @@ -36,21 +36,21 @@ class ChangeEmailValidator < ActiveRecord::BaseWithoutTable def validate if !self.old_email.blank? && !MySociety::Validate.is_valid_email(self.old_email) - errors.add(:old_email, "Old email doesn't look like a valid address") + errors.add(:old_email, _("Old email doesn't look like a valid address")) end if !errors[:old_email] if self.old_email.downcase != self.logged_in_user.email.downcase - errors.add(:old_email, "Old email address isn't the same as the address of the account you are logged in with") + errors.add(:old_email, _("Old email address isn't the same as the address of the account you are logged in with")) elsif (!self.changing_email) && (!self.logged_in_user.has_this_password?(self.password)) if !errors[:password] - errors.add(:password, "Password is not correct") + errors.add(:password, _("Password is not correct")) end end end if !self.new_email.blank? && !MySociety::Validate.is_valid_email(self.new_email) - errors.add(:new_email, "New email doesn't look like a valid address") + errors.add(:new_email, _("New email doesn't look like a valid address")) end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 3d69b1108..b7ece9ba9 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -56,10 +56,10 @@ class Comment < ActiveRecord::Base # Check have edited comment def validate if self.body.empty? || self.body =~ /^\s+$/ - errors.add(:body, N_("Please enter your annotation")) + errors.add(:body, _("Please enter your annotation")) end if !MySociety::Validate.uses_mixed_capitals(self.body) - errors.add(:body, N_('Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.')) + errors.add(:body, _('Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.')) end end diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb index 9d8c54095..0bc562835 100644 --- a/app/models/contact_validator.rb +++ b/app/models/contact_validator.rb @@ -31,7 +31,7 @@ class ContactValidator < ActiveRecord::BaseWithoutTable validates_presence_of :message, :message => N_("Please enter the message you want to send") def validate - errors.add(:email, "Email doesn't look like a valid address") unless MySociety::Validate.is_valid_email(self.email) + errors.add(:email, _("Email doesn't look like a valid address")) unless MySociety::Validate.is_valid_email(self.email) end end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index cab28b8f1..a36b140b8 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -57,6 +57,8 @@ class InfoRequest < ActiveRecord::Base 'waiting_response', 'waiting_clarification', 'gone_postal', + 'deadline_extended', + 'wrong_response', 'not_held', 'rejected', # this is called 'refused' in UK FOI law and the user interface, but 'rejected' internally for historic reasons 'successful', @@ -511,6 +513,9 @@ public # waiting_response_very_overdue def calculate_status return 'waiting_classification' if self.awaiting_description + # if deadline_extended expired do waiting_response_overdue + return 'waiting_response_overdue' if + self.described_state == "deadline_extended" && Time.now.strftime("%Y-%m-%d") > self.date_deadline_extended.strftime("%Y-%m-%d") return described_state unless self.described_state == "waiting_response" # Compare by date, so only overdue on next day, not if 1 second late return 'waiting_response_very_overdue' if @@ -607,7 +612,7 @@ public # last_event_forming_initial_request. There may be more obscure # things, e.g. fees, not properly covered. def date_response_required_by - return Holiday.due_date_from(self.date_initial_request_last_sent_at, 20) + return Holiday.due_date_from(self.date_initial_request_last_sent_at, 7) end # This is a long stop - even with UK public interest test extensions, 40 # days is a very long time. @@ -621,7 +626,10 @@ public return Holiday.due_date_from(self.date_initial_request_last_sent_at, 40) end end - + # deadline_extended + def date_deadline_extended + return Holiday.due_date_from(self.date_initial_request_last_sent_at, 15) + end # Where the initial request is sent to def recipient_email return self.public_body.request_email @@ -741,35 +749,39 @@ public def display_status status = self.calculate_status if status == 'waiting_classification' - "Awaiting classification." + _("Awaiting classification.") elsif status == 'waiting_response' - "Awaiting response." + _("Awaiting response.") elsif status == 'waiting_response_overdue' - "Delayed." + _("Delayed.") elsif status == 'waiting_response_very_overdue' - "Long overdue." + _("Long overdue.") elsif status == 'not_held' - "Information not held." + _("Information not held.") elsif status == 'rejected' - "Refused." + _("Refused.") elsif status == 'partially_successful' - "Partially successful." + _("Partially successful.") elsif status == 'successful' - "Successful." + _("Successful.") elsif status == 'waiting_clarification' - "Waiting clarification." + _("Waiting clarification.") elsif status == 'gone_postal' - "Handled by post." + _("Handled by post.") + elsif status == 'deadline_extended' + _("Deadline extended.") + elsif status == 'wrong_response' + _("Wrong Response.") elsif status == 'internal_review' - "Awaiting internal review." + _("Awaiting internal review.") elsif status == 'error_message' - "Delivery error" + _("Delivery error") elsif status == 'requires_admin' - "Unusual response." + _("Unusual response.") elsif status == 'user_withdrawn' - "Withdrawn by the requester." + _("Withdrawn by the requester.") else - raise "unknown status " + status + raise _("unknown status ") + status end end diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 1b22fa547..02b9a34ac 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -62,6 +62,8 @@ class InfoRequestEvent < ActiveRecord::Base 'waiting_response', 'waiting_clarification', 'gone_postal', + 'deadline_extended', + 'wrong_response', 'not_held', 'rejected', 'successful', @@ -283,27 +285,31 @@ class InfoRequestEvent < ActiveRecord::Base status = self.calculated_state if !status.nil? if status == 'waiting_response' - return "Acknowledgement" + return _("Acknowledgement") elsif status == 'waiting_clarification' - return "Clarification required" + return _("Clarification required") elsif status == 'gone_postal' - return "Handled by post" + return _("Handled by post") + elsif status == 'deadline_extended' + return _("Deadline Extended") + elsif status == 'wrong_response' + return _("Wrong Response") elsif status == 'not_held' - return "Information not held" + return _("Information not held") elsif status == 'rejected' - return "Refused" + return _("Refused") elsif status == 'partially_successful' - return "Some information sent" + return _("Some information sent") elsif status == 'successful' - return "All information sent" + return _("All information sent") elsif status == 'internal_review' - return "Internal review acknowledgement" + return _("Internal review acknowledgement") elsif status == 'user_withdrawn' - return "Withdrawn by requester" + return _("Withdrawn by requester") elsif status == 'error_message' - return "Delivery error" + return _("Delivery error") elsif status == 'requires_admin' - return "Unusual response" + return _("Unusual response") end raise "unknown status " + status end @@ -314,17 +320,17 @@ class InfoRequestEvent < ActiveRecord::Base status = self.calculated_state if !status.nil? if status == 'internal_review' - return "Internal review request" + return _("Internal review request") end if status == 'waiting_response' - return "Clarification" + return _("Clarification") end - raise "unknown status " + status + raise _("unknown status ") + status end - return "Follow up" + return _("Follow up") end - raise "display_status only works for incoming and outgoing messages right now" + raise _("display_status only works for incoming and outgoing messages right now") end def is_sent_sort? diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 220f4f0a7..f9baad9b0 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -54,7 +54,7 @@ class OutgoingMessage < ActiveRecord::Base # How the default letter starts and ends def get_salutation - ret = "Dear " + ret = _("Dear ") if self.message_type == 'followup' && !self.incoming_message_followup.nil? && !self.incoming_message_followup.safe_mail_from.nil? && self.incoming_message_followup.valid_to_reply_to? ret = ret + OutgoingMailer.name_for_followup(self.info_request, self.incoming_message_followup) else @@ -64,13 +64,13 @@ class OutgoingMessage < ActiveRecord::Base end def get_signoff if self.message_type == 'followup' && !self.incoming_message_followup.nil? && !self.incoming_message_followup.safe_mail_from.nil? && self.incoming_message_followup.valid_to_reply_to? - return "Yours sincerely," + return _("Yours sincerely,") else - return "Yours faithfully," + return _("Yours faithfully,") end end def get_internal_review_insert_here_note - return "GIVE DETAILS ABOUT YOUR COMPLAINT HERE" + return _("GIVE DETAILS ABOUT YOUR COMPLAINT HERE") end def get_default_letter if self.default_letter diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 520e28aab..b68722b81 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -54,23 +54,30 @@ class PublicBody < ActiveRecord::Base # like find_by_url_name but also search historic url_name if none found def self.find_by_url_name_with_historic(name) - found = PublicBody.find_all_by_url_name(name) - return found.first if found.size == 1 - # Shouldn't we just make url_name unique? - raise "Two bodies with the same URL name: #{name}" if found.size > 1 - # If none found, then search the history of short names - old = PublicBody::Version.find_all_by_url_name(name) - # Find unique public bodies in it - old = old.map { |x| x.public_body_id } - old = old.uniq - # Maybe return the first one, so we show something relevant, - # rather than throwing an error? - raise "Two bodies with the same historical URL name: #{name}" if old.size > 1 - return unless old.size == 1 - # does acts_as_versioned provide a method that returns the current version? - return PublicBody.find(old.first) + @localer = I18n.locale.to_s + PublicBody.with_locale(@locale) do + found = PublicBody.find(:all, + :conditions => ["public_body_translations.url_name='#{name}' AND public_body_translations.locale = '#{@localer}'"], + :joins => :translations) + return found.first if found.size == 1 + # Shouldn't we just make url_name unique? + raise "Two bodies with the same URL name: #{name}" if found.size > 1 + # If none found, then search the history of short names + old = PublicBody::Version.find_all_by_url_name(name) + # Find unique public bodies in it + old = old.map { |x| x.public_body_id } + old = old.uniq + # Maybe return the first one, so we show something relevant, + # rather than throwing an error? + raise "Two bodies with the same historical URL name: #{name}" if old.size > 1 + return unless old.size == 1 + # does acts_as_versioned provide a method that returns the current version? + return PublicBody.find(old.first) + end end + + load "public_body_categories_#{I18n.locale.to_s}.rb" # Set the first letter, which is used for faster queries before_save(:set_first_letter) @@ -278,6 +285,7 @@ class PublicBody < ActiveRecord::Base :request_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost'), :home_page => "", :notes => "", + :publication_scheme => "", :last_edit_editor => "internal_admin", :last_edit_comment => "Made by PublicBody.internal_admin_body" ) @@ -343,7 +351,7 @@ class PublicBody < ActiveRecord::Base else # New public body notes.push "line " + line.to_s + ": new authority '" + name + "' with email " + email - public_body = PublicBody.new(:name => name, :request_email => email, :short_name => "", :home_page => "", :notes => "", :last_edit_editor => editor, :last_edit_comment => 'Created from spreadsheet') + public_body = PublicBody.new(:name => name, :request_email => email, :short_name => "", :home_page => "", :publication_scheme => "", :notes => "", :last_edit_editor => editor, :last_edit_comment => 'Created from spreadsheet') public_body.tag_string = tag public_body.save! end diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 9d6f40ed7..aee1ed1da 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -152,15 +152,15 @@ class TrackThing < ActiveRecord::Base @params = { # Website :list_description => "any <a href=\"/list/successful\">successful requests</a>", - :verb_on_page => "Email me new successful responses", - :verb_on_page_already => "You are being emailed about any new successful responses", + :verb_on_page => _("Email me new successful responses "), + :verb_on_page_already => _("You are being emailed about any new successful responses"), # Email - :title_in_email => "Successful Freedom of Information requests", - :title_in_rss => "Successful Freedom of Information requests", + :title_in_email => _("Successful Freedom of Information requests"), + :title_in_rss => _("Successful Freedom of Information requests"), # Authentication - :web => "To be emailed about any successful requests", - :email => "Then you will be emailed whenever an FOI request succeeds.", - :email_subject => "Confirm you want to be emailed when an FOI request succeeds", + :web => _("To be emailed about any successful requests"), + :email => _("Then you will be emailed whenever an FOI request succeeds."), + :email_subject => _("Confirm you want to be emailed when an FOI request succeeds"), # RSS sorting - used described date, as newest would give a # date for responses possibly days before description, so # wouldn't appear at top of list when description (known @@ -171,7 +171,7 @@ class TrackThing < ActiveRecord::Base @params = { # Website :list_description => "'<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>', a public authority", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how - :verb_on_page => "Track requests to " + CGI.escapeHTML(self.public_body.name) + " by email", + :verb_on_page => _("Track requests to {{public_body_name}} by email",:public_body_name=>CGI.escapeHTML(self.public_body.name)), :verb_on_page_already => "You are already tracking requests to " + CGI.escapeHTML(self.public_body.name) + " by email", # Email :title_in_email => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'", diff --git a/app/models/user.rb b/app/models/user.rb index 2fd6d9dbe..e199eb352 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -31,11 +31,11 @@ require 'digest/sha1' class User < ActiveRecord::Base strip_attributes! - validates_presence_of :email, :message => N_("Please enter your email address") + validates_presence_of :email, :message => _("Please enter your email address") - validates_presence_of :name, :message => N_("Please enter your name") + validates_presence_of :name, :message => _("Please enter your name") - validates_presence_of :hashed_password, :message => N_("Please enter a password") + validates_presence_of :hashed_password, :message => _("Please enter a password") has_many :info_requests, :order => 'created_at desc' has_many :user_info_request_sent_alerts @@ -46,7 +46,7 @@ class User < ActiveRecord::Base has_many :censor_rules, :order => 'created_at desc' attr_accessor :password_confirmation, :no_xapian_reindex - validates_confirmation_of :password, :message => N_("Please enter the same password twice") + validates_confirmation_of :password, :message => _("Please enter the same password twice") validates_inclusion_of :admin_level, :in => [ 'none', @@ -103,10 +103,10 @@ class User < ActiveRecord::Base def validate if self.email != "" && !MySociety::Validate.is_valid_email(self.email) - errors.add(:email, N_("Please enter a valid email address")) + errors.add(_("Please enter a valid email address")) end if MySociety::Validate.is_valid_email(self.name) - errors.add(:name, N_("Please enter your name, not your email address, in the name field.")) + errors.add(:name, _("Please enter your name, not your email address, in the name field.")) end end @@ -129,9 +129,9 @@ class User < ActiveRecord::Base params[:email].strip! if specific_user_login - auth_fail_message = "Either the email or password was not recognised, please try again." + auth_fail_message = _("Either the email or password was not recognised, please try again.") else - auth_fail_message = "Either the email or password was not recognised, please try again. Or create a new account using the form on the right." + auth_fail_message = _("Either the email or password was not recognised, please try again. Or create a new account using the form on the right.") end user = self.find_user_by_email(params[:email]) diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb index 70ca42675..f164f684e 100644 --- a/app/models/user_mailer.rb +++ b/app/models/user_mailer.rb @@ -31,7 +31,7 @@ class UserMailer < ApplicationMailer @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from # we don't care about bounces when people are fiddling with their account @recipients = new_email - @subject = "Confirm your new email address on WhatDoTheyKnow.com" + @subject = _("Confirm your new email address on WhatDoTheyKnow.com") @body[:name] = user.name @body[:url] = url @body[:old_email] = user.email @@ -42,7 +42,7 @@ class UserMailer < ApplicationMailer @from = contact_from_name_and_email headers 'Return-Path' => blackhole_email, 'Reply-To' => @from # we don't care about bounces when people are fiddling with their account @recipients = new_email - @subject = "Unable to change email address on WhatDoTheyKnow.com" + @subject = _("Unable to change email address on WhatDoTheyKnow.com") @body[:old_email] = old_email @body[:new_email] = new_email end |