aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/info_request_event.rb42
-rw-r--r--app/models/post_redirect.rb2
-rw-r--r--app/models/request_mailer.rb2
-rw-r--r--app/models/track_thing.rb12
4 files changed, 33 insertions, 25 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 99f34cf9e..cb49596cb 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -36,25 +36,29 @@ class InfoRequestEvent < ActiveRecord::Base
has_many :track_things_sent_emails
validates_presence_of :event_type
- validates_inclusion_of :event_type, :in => [
- 'sent',
- 'resent',
- 'followup_sent',
- 'followup_resent',
-
- 'edit', # title etc. edited (in admin interface)
- 'edit_outgoing', # outgoing message edited (in admin interface)
- 'edit_comment', # comment edited (in admin interface)
- 'destroy_incoming', # deleted an incoming message (in admin interface)
- 'destroy_outgoing', # deleted an outgoing message (in admin interface)
- 'redeliver_incoming', # redelivered an incoming message elsewhere (in admin interface)
- 'move_request', # changed user or public body (in admin interface)
- 'manual', # you did something in the db by hand
-
- 'response',
- 'comment',
- 'status_update'
- ]
+
+ def self.enumerate_event_types
+ [
+ 'sent',
+ 'resent',
+ 'followup_sent',
+ 'followup_resent',
+
+ 'edit', # title etc. edited (in admin interface)
+ 'edit_outgoing', # outgoing message edited (in admin interface)
+ 'edit_comment', # comment edited (in admin interface)
+ 'destroy_incoming', # deleted an incoming message (in admin interface)
+ 'destroy_outgoing', # deleted an outgoing message (in admin interface)
+ 'redeliver_incoming', # redelivered an incoming message elsewhere (in admin interface)
+ 'move_request', # changed user or public body (in admin interface)
+ 'manual', # you did something in the db by hand
+
+ 'response',
+ 'comment',
+ 'status_update',
+ ]
+ end
+ validates_inclusion_of :event_type, :in => enumerate_event_types
# user described state (also update in info_request)
validate :must_be_valid_state
diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb
index 59cc86799..c9a6229a4 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -39,7 +39,7 @@ class PostRedirect < ActiveRecord::Base
self.post_params_yaml = params.to_yaml
end
def post_params
- if self.post_params_yaml.nil?
+ if self.post_params_yaml.nil?
return {}
end
YAML.load(self.post_params_yaml)
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb
index 83cce9045..177a39241 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -40,7 +40,7 @@ class RequestMailer < ApplicationMailer
:filename => "original.eml", :transfer_encoding => '7bit', :content_disposition => 'inline'
@body = {
:info_request => info_request,
- :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost')
+ :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost')
}
end
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index 58d70ed86..b277e72b0 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -146,11 +146,15 @@ class TrackThing < ActiveRecord::Base
return track_thing
end
- def TrackThing.create_track_for_public_body(public_body)
+ def TrackThing.create_track_for_public_body(public_body, event_type = nil)
track_thing = TrackThing.new
track_thing.track_type = 'public_body_updates'
track_thing.public_body = public_body
- track_thing.track_query = "requested_from:" + public_body.url_name
+ query = "requested_from:" + public_body.url_name
+ if InfoRequestEvent.enumerate_event_types.include?(event_type)
+ query += " variety:" + event_type
+ end
+ track_thing.track_query = query
return track_thing
end
@@ -172,9 +176,9 @@ class TrackThing < ActiveRecord::Base
when "users"
query += " variety:user"
when "authorities"
- query += " variety:authority"
+ query += " variety:authority"
end
- end
+ end
track_thing.track_query = query
# XXX should extract requested_by:, request:, requested_from:
# and stick their values into the respective relations.