aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/track_thing.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/track_thing.rb')
-rw-r--r--app/models/track_thing.rb92
1 files changed, 48 insertions, 44 deletions
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index 58d70ed86..d0fc62e12 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 108
+# Schema version: 114
#
# Table name: track_things
#
@@ -35,17 +35,17 @@ class TrackThing < ActiveRecord::Base
has_many :track_things_sent_emails
- validates_inclusion_of :track_type, :in => [
- 'request_updates',
+ validates_inclusion_of :track_type, :in => [
+ 'request_updates',
'all_new_requests',
'all_successful_requests',
- 'public_body_updates',
+ 'public_body_updates',
'user_updates',
'search_query'
]
- validates_inclusion_of :track_medium, :in => [
- 'email_daily',
+ validates_inclusion_of :track_medium, :in => [
+ 'email_daily',
'feed'
]
@@ -69,7 +69,7 @@ class TrackThing < ActiveRecord::Base
end
def track_query_description
- # XXX this is very brittle... we should probably ask users
+ # XXX this is very brittle... we should probably ask users
# simply to name their tracks when they make them?
original_text = parsed_text = self.track_query.gsub(/([()]|OR)/, "")
filters = parsed_text.scan /\b\S+:\S+\b/
@@ -101,14 +101,14 @@ class TrackThing < ActiveRecord::Base
end
if filter =~ /waiting/
statuses << _("awaiting a response")
- end
+ end
end
if filters.empty?
parsed_text = original_text
end
descriptions = []
if varieties.include? _("requests")
- descriptions << _("requests which are {{list_of_statuses}}", :list_of_statuses => Array(statuses).join(_(' or ')))
+ descriptions << _("requests which are {{list_of_statuses}}", :list_of_statuses => Array(statuses).sort.join(_(' or ')))
varieties -= [_("requests")]
end
if descriptions.empty? and varieties.empty?
@@ -116,7 +116,7 @@ class TrackThing < ActiveRecord::Base
end
descriptions += Array(varieties)
parsed_text = parsed_text.strip
- descriptions = descriptions.join(_(" or "))
+ descriptions = descriptions.sort.join(_(" or "))
if !parsed_text.empty?
descriptions += _("{{list_of_things}} matching text '{{search_query}}'", :list_of_things => "", :search_query => parsed_text)
end
@@ -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
@@ -171,10 +175,10 @@ class TrackThing < ActiveRecord::Base
query += " variety:sent"
when "users"
query += " variety:user"
- when "authorities"
- query += " variety:authority"
+ when "bodies"
+ 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.
@@ -192,15 +196,15 @@ class TrackThing < ActiveRecord::Base
@params = {
# Website
:list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
- :verb_on_page => _("Track this request by email"),
- :verb_on_page_already => _("You are already tracking this request by email"),
+ :verb_on_page => _("Follow this request"),
+ :verb_on_page_already => _("You are already following this request"),
# Email
:title_in_email => _("New updates for the request '{{request_title}}'", :request_title => self.info_request.title),
:title_in_rss => _("New updates for the request '{{request_title}}'", :request_title => self.info_request.title),
# Authentication
- :web => _("To follow updates to the request '{{request_title}}'", :request_title => CGI.escapeHTML(self.info_request.title)),
- :email => _("Then you will be emailed whenever the request '{{request_title}}' is updated.", :request_title => CGI.escapeHTML(self.info_request.title)),
- :email_subject => _("Confirm you want to follow updates to the request '{{request_title}}'", :request_title => self.info_request.title),
+ :web => _("To follow the request '{{request_title}}'", :request_title => CGI.escapeHTML(self.info_request.title)),
+ :email => _("Then you will be updated whenever the request '{{request_title}}' is updated.", :request_title => CGI.escapeHTML(self.info_request.title)),
+ :email_subject => _("Confirm you want to follow the request '{{request_title}}'", :request_title => self.info_request.title),
# RSS sorting
:feed_sortby => 'newest'
}
@@ -208,15 +212,15 @@ class TrackThing < ActiveRecord::Base
@params = {
# Website
:list_description => _("any <a href=\"/list\">new requests</a>"),
- :verb_on_page => _("Email me when there are new requests"),
- :verb_on_page_already => _("You are being emailed when there are new requests"),
+ :verb_on_page => _("Follow all new requests"),
+ :verb_on_page_already => _("You are already following new requests"),
# Email
:title_in_email => _("New Freedom of Information requests"),
:title_in_rss => _("New Freedom of Information requests"),
# Authentication
- :web => _("To be emailed about any new requests"),
- :email => _("Then you will be emailed whenever anyone makes a new FOI request."),
- :email_subject => _("Confirm you want to be emailed about new requests"),
+ :web => _("To follow new requests"),
+ :email => _("Then you will be following all new FOI requests."),
+ :email_subject => _("Confirm you want to follow new requests"),
# RSS sorting
:feed_sortby => 'newest'
}
@@ -224,15 +228,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 => _("Follow new successful responses"),
+ :verb_on_page_already => _("You are following all new successful responses"),
# Email
: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 follow all successful requests"),
+ :email => _("Then you will be notified whenever an FOI request succeeds."),
+ :email_subject => _("Confirm you want to follow all successful FOI requests"),
# 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
@@ -243,15 +247,15 @@ class TrackThing < ActiveRecord::Base
@params = {
# Website
:list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # 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 {{public_body_name}} by email",:public_body_name=>CGI.escapeHTML(self.public_body.name)),
- :verb_on_page_already => _("You are already tracking requests to {{public_body_name}} by email", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
+ :verb_on_page => _("Follow requests to {{public_body_name}}",:public_body_name=>CGI.escapeHTML(self.public_body.name)),
+ :verb_on_page_already => _("You are already following requests to {{public_body_name}}", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
# Email
:title_in_email => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'",
:title_in_rss => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'",
# Authentication
- :web => _("To be emailed about requests made using {{site_name}} to the public authority '{{public_body_name}}'", :site_name=>MySociety::Config.get('SITE_NAME', 'Alaveteli'), :public_body_name=>CGI.escapeHTML(self.public_body.name)),
- :email => _("Then you will be emailed whenever someone requests something or gets a response from '{{public_body_name}}'.", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
- :email_subject => _("Confirm you want to be emailed about requests to '{{public_body_name}}'", :public_body_name=>self.public_body.name),
+ :web => _("To follow requests made using {{site_name}} to the public authority '{{public_body_name}}'", :site_name=>MySociety::Config.get('SITE_NAME', 'Alaveteli'), :public_body_name=>CGI.escapeHTML(self.public_body.name)),
+ :email => _("Then you will be notified whenever someone requests something or gets a response from '{{public_body_name}}'.", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
+ :email_subject => _("Confirm you want to follow requests to '{{public_body_name}}'", :public_body_name=>self.public_body.name),
# RSS sorting
:feed_sortby => 'newest'
}
@@ -259,15 +263,15 @@ class TrackThing < ActiveRecord::Base
@params = {
# Website
:list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
- :verb_on_page => _("Track this person by email"),
- :verb_on_page_already => _("You are already tracking this person by email"),
+ :verb_on_page => _("Follow this person"),
+ :verb_on_page_already => _("You are already following this person"),
# Email
:title_in_email => _("FOI requests by '{{user_name}}'", :user_name=>self.tracked_user.name),
:title_in_rss => _("FOI requests by '{{user_name}}'", :user_name=>self.tracked_user.name),
# Authentication
- :web => _("To be emailed about requests by '{{user_name}}'", :user_name=>CGI.escapeHTML(self.tracked_user.name)),
- :email => _("Then you will be emailed whenever '{{user_name}}' requests something or gets a response.", :user_name=>CGI.escapeHTML(self.tracked_user.name)),
- :email_subject => _("Confirm you want to be emailed about requests by '{{user_name}}'", :user_name=>self.tracked_user.name),
+ :web => _("To follow requests by '{{user_name}}'", :user_name=>CGI.escapeHTML(self.tracked_user.name)),
+ :email => _("Then you will be notified whenever '{{user_name}}' requests something or gets a response.", :user_name=>CGI.escapeHTML(self.tracked_user.name)),
+ :email_subject => _("Confirm you want to follow requests by '{{user_name}}'", :user_name=>self.tracked_user.name),
# RSS sorting
:feed_sortby => 'newest'
}
@@ -275,15 +279,15 @@ class TrackThing < ActiveRecord::Base
@params = {
# Website
:list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
- :verb_on_page => _("Track things matching this search by email"),
- :verb_on_page_already => _("You are already tracking things matching this search by email"),
+ :verb_on_page => _("Follow things matching this search"),
+ :verb_on_page_already => _("You are already following things matching this search"),
# Email
:title_in_email => _("Requests or responses matching your saved search"),
:title_in_rss => _("Requests or responses matching your saved search"),
# Authentication
:web => _("To follow requests and responses matching your search"),
- :email => _("Then you will be emailed whenever a new request or response matches your search."),
- :email_subject => _("Confirm you want to be emailed about new requests or responses matching your search"),
+ :email => _("Then you will be notified whenever a new request or response matches your search."),
+ :email_subject => _("Confirm you want to follow new requests or responses matching your search"),
# RSS sorting - XXX hmmm, we don't really know which to use
# here for sorting. Might be a query term (e.g. 'cctv'), in
# which case newest is good, or might be something like