aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorseb <seb@seb-U36JC>2011-11-24 09:21:36 +0000
committerseb <seb@seb-U36JC>2011-11-24 09:21:36 +0000
commita4e533f1588a5d34dca4ab462b58ddd83eed37c5 (patch)
tree58bb3b57ec5664e094ae151c18b6c1915256e364 /app/models/info_request.rb
parentd473fce1d0451c913d3ef697d3b45bd58c6fff54 (diff)
parente649c2a7f19d0a75206149d886ff47b3ccda4e91 (diff)
Merge branch 'develop' into xapian-dcabo
Conflicts: spec/models/xapian_spec.rb
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb41
1 files changed, 24 insertions, 17 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index c667e1499..f482ca700 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -117,13 +117,13 @@ class InfoRequest < ActiveRecord::Base
# only check on create, so existing models with mixed case are allowed
def validate_on_create
if !self.title.nil? && !MySociety::Validate.uses_mixed_capitals(self.title, 10)
- errors.add(:title, N_('Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.'))
+ errors.add(:title, _('Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.'))
end
if !self.title.nil? && title.size > 200
- errors.add(:title, N_('Please keep the summary short, like in the subject of an email. You can use a phrase, rather than a full sentence.'))
+ errors.add(:title, _('Please keep the summary short, like in the subject of an email. You can use a phrase, rather than a full sentence.'))
end
if !self.title.nil? && self.title =~ /^(FOI|Freedom of Information)\s*requests?$/i
- errors.add(:title, N_('Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.'))
+ errors.add(:title, _('Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.'))
end
end
@@ -240,9 +240,9 @@ public
# into some sort of separate jurisdiction dependent file
if self.public_body.url_name == 'general_register_office'
# without GQ in the subject, you just get an auto response
- self.law_used_full + ' request GQ - ' + self.title
+ _('{{law_used_full}} request GQ - {{title}}',:law_used_full=>self.law_used_full,:title=>self.title)
else
- self.law_used_full + ' request - ' + self.title
+ _('{{law_used_full}} request - {{title}}',:law_used_full=>self.law_used_full,:title=>self.title)
end
end
def email_subject_followup(incoming_message = nil)
@@ -260,36 +260,36 @@ public
# Two sorts of laws for requests, FOI or EIR
def law_used_full
if self.law_used == 'foi'
- return "Freedom of Information"
+ return _("Freedom of Information")
elsif self.law_used == 'eir'
- return "Environmental Information Regulations"
+ return _("Environmental Information Regulations")
else
raise "Unknown law used '" + self.law_used + "'"
end
end
def law_used_short
if self.law_used == 'foi'
- return "FOI"
+ return _("FOI")
elsif self.law_used == 'eir'
- return "EIR"
+ return _("EIR")
else
raise "Unknown law used '" + self.law_used + "'"
end
end
def law_used_act
if self.law_used == 'foi'
- return "Freedom of Information Act"
+ return _("Freedom of Information Act")
elsif self.law_used == 'eir'
- return "Environmental Information Regulations"
+ return _("Environmental Information Regulations")
else
raise "Unknown law used '" + self.law_used + "'"
end
end
def law_used_with_a
if self.law_used == 'foi'
- return "A Freedom of Information request"
+ return _("A Freedom of Information request")
elsif self.law_used == 'eir'
- return "An Environmental Information Regulations request"
+ return _("An Environmental Information Regulations request")
else
raise "Unknown law used '" + self.law_used + "'"
end
@@ -451,7 +451,7 @@ public
self.log_event("response", params)
self.save!
end
-
+ self.info_request_events.each { |event| event.xapian_mark_needs_index } # for the "waiting_classification" index
RequestMailer.deliver_new_response(self, incoming_message)
end
@@ -564,6 +564,7 @@ public
def calculate_event_states
curr_state = nil
for event in self.info_request_events.reverse
+ event.xapian_mark_needs_index # we need to reindex all events in order to update their latest_* terms
if curr_state.nil?
if !event.described_state.nil?
curr_state = event.described_state
@@ -779,8 +780,7 @@ public
# Display version of status
- def display_status
- status = self.calculate_status
+ def InfoRequest.get_status_description(status)
if status == 'waiting_classification'
_("Awaiting classification.")
elsif status == 'waiting_response'
@@ -818,6 +818,10 @@ public
end
end
+ def display_status
+ InfoRequest.get_status_description(self.calculate_status)
+ end
+
# Completely delete this request and all objects depending on it
def fully_destroy
self.track_things.each do |track_thing|
@@ -918,10 +922,13 @@ public
end
# List of incoming messages to followup, by unique email
- def who_can_followup_to
+ def who_can_followup_to(skip_message = nil)
ret = []
done = {}
for incoming_message in self.incoming_messages.reverse
+ if incoming_message == skip_message
+ next
+ end
incoming_message.safe_mail_from
email = OutgoingMailer.email_for_followup(self, incoming_message)