aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorfrancis <francis>2008-04-01 16:40:37 +0000
committerfrancis <francis>2008-04-01 16:40:37 +0000
commitbaa530c0c8f5fb1e12173fbfde8f722ebeffe5be (patch)
treed80dd72953de39723d3208f78247052352e85fb1 /app/models
parent708480da65908e38e00cfa1eaef9b7f04cc9a4a6 (diff)
Skeleton of tracking / alerting / email.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/contact_validator.rb4
-rw-r--r--app/models/incoming_message.rb4
-rw-r--r--app/models/info_request.rb4
-rw-r--r--app/models/info_request_event.rb19
-rw-r--r--app/models/outgoing_message.rb4
-rw-r--r--app/models/post_redirect.rb4
-rw-r--r--app/models/public_body.rb4
-rw-r--r--app/models/public_body_tag.rb4
-rw-r--r--app/models/track_thing.rb54
-rw-r--r--app/models/track_things_sent_email.rb27
-rw-r--r--app/models/user.rb4
-rw-r--r--app/models/user_info_request_sent_alert.rb4
12 files changed, 109 insertions, 27 deletions
diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb
index 1ed55e34f..3af6ee2e8 100644
--- a/app/models/contact_validator.rb
+++ b/app/models/contact_validator.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: contact_validators
#
@@ -15,7 +15,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: contact_validator.rb,v 1.9 2008-03-31 19:15:38 francis Exp $
+# $Id: contact_validator.rb,v 1.10 2008-04-01 16:40:37 francis Exp $
class ContactValidator < ActiveRecord::BaseWithoutTable
column :name, :string
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index bb286dc14..41ffa029c 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: incoming_messages
#
@@ -17,7 +17,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: incoming_message.rb,v 1.71 2008-03-31 19:15:38 francis Exp $
+# $Id: incoming_message.rb,v 1.72 2008-04-01 16:40:37 francis Exp $
# TODO
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 1bc6004aa..1633aec3d 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: info_requests
#
@@ -22,7 +22,7 @@
# 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.78 2008-03-31 23:19:16 francis Exp $
+# $Id: info_request.rb,v 1.79 2008-04-01 16:40:37 francis Exp $
require 'digest/sha1'
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index ef3d729f6..e07d645dd 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -1,15 +1,16 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: info_request_events
#
-# id :integer not null, primary key
-# info_request_id :integer not null
-# event_type :text not null
-# params_yaml :text not null
-# created_at :datetime not null
-# described_state :string(255)
-# calculated_state :string(255)
+# id :integer not null, primary key
+# info_request_id :integer not null
+# 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
#
# models/info_request_event.rb:
@@ -17,7 +18,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request_event.rb,v 1.32 2008-04-01 06:13:02 francis Exp $
+# $Id: info_request_event.rb,v 1.33 2008-04-01 16:40:37 francis Exp $
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index 568115d7b..f651aea08 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: outgoing_messages
#
@@ -21,7 +21,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: outgoing_message.rb,v 1.40 2008-03-31 19:15:38 francis Exp $
+# $Id: outgoing_message.rb,v 1.41 2008-04-01 16:40:37 francis Exp $
class OutgoingMessage < ActiveRecord::Base
belongs_to :info_request
diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb
index d1a8a8eb7..03fcbe564 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: post_redirects
#
@@ -26,7 +26,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: post_redirect.rb,v 1.27 2008-03-31 19:15:38 francis Exp $
+# $Id: post_redirect.rb,v 1.28 2008-04-01 16:40:37 francis Exp $
require 'openssl' # for random bytes function
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 2c31278bb..f82e17038 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: public_bodies
#
@@ -21,7 +21,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: public_body.rb,v 1.49 2008-03-31 19:15:38 francis Exp $
+# $Id: public_body.rb,v 1.50 2008-04-01 16:40:37 francis Exp $
require 'csv'
require 'set'
diff --git a/app/models/public_body_tag.rb b/app/models/public_body_tag.rb
index e7c2c7024..b2e287d95 100644
--- a/app/models/public_body_tag.rb
+++ b/app/models/public_body_tag.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: public_body_tags
#
@@ -15,7 +15,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: public_body_tag.rb,v 1.7 2008-03-31 19:15:38 francis Exp $
+# $Id: public_body_tag.rb,v 1.8 2008-04-01 16:40:37 francis Exp $
class PublicBodyTag < ActiveRecord::Base
validates_presence_of :public_body
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
new file mode 100644
index 000000000..35f384e5c
--- /dev/null
+++ b/app/models/track_thing.rb
@@ -0,0 +1,54 @@
+# == Schema Information
+# Schema version: 49
+#
+# 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
+# track_medium :string(255) not null
+#
+
+# models/track_thing.rb:
+# When somebody is getting alerts for something.
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: track_thing.rb,v 1.1 2008-04-01 16:40:37 francis Exp $
+
+class TrackThing < ActiveRecord::Base
+ belongs_to :user, :foreign_key => 'tracking_user_id'
+ validates_presence_of :track_query
+
+ belongs_to :info_request
+ belongs_to :public_body
+ belongs_to :user, :foreign_key => 'tracked_user_id'
+
+ validates_inclusion_of :track_medium, :in => [
+ 'email_daily',
+ ]
+
+ attr_accessor :params
+
+ def TrackThing.create_track_for_request(info_request)
+ track_thing = TrackThing.new
+ track_thing.info_request = info_request
+ track_thing.params = {
+ :title => "Track the request '" + CGI.escapeHTML(info_request.title) + "'",
+ :feed_sortby => 'described',
+
+ :web => "To follow updates to the request '" + CGI.escapeHTML(info_request.title) + "'",
+ :email => "Then you will be emailed whenever the request '" + CGI.escapeHTML(info_request.title) + "' is updated.",
+ :email_subject => "Confirm you want to follow updates to the request '" + CGI.escapeHTML(info_request.title) + "'",
+ }
+ track_thing.track_query = "request:" + info_request.url_title
+ return track_thing
+ end
+
+end
+
+
diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb
new file mode 100644
index 000000000..d177d427c
--- /dev/null
+++ b/app/models/track_things_sent_email.rb
@@ -0,0 +1,27 @@
+# == Schema Information
+# Schema version: 49
+#
+# 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
+#
+
+# models/track_things_sent_email.rb:
+# Record that alert has arrived.
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: track_things_sent_email.rb,v 1.1 2008-04-01 16:40:37 francis Exp $
+
+class TrackThingsSentEmail < ActiveRecord::Base
+ belongs_to :info_request_event
+ belongs_to :user
+ belongs_to :public_body
+end
+
+
diff --git a/app/models/user.rb b/app/models/user.rb
index 4d62d0b93..28b1e5b28 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 47
+# Schema version: 49
#
# Table name: users
#
@@ -20,7 +20,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user.rb,v 1.43 2008-03-31 19:15:38 francis Exp $
+# $Id: user.rb,v 1.44 2008-04-01 16:40:37 francis Exp $
require 'digest/sha1'
diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb
index e83c2b57f..485620805 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: 47
+# Schema version: 49
#
# Table name: user_info_request_sent_alerts
#
@@ -17,7 +17,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user_info_request_sent_alert.rb,v 1.9 2008-03-31 19:15:38 francis Exp $
+# $Id: user_info_request_sent_alert.rb,v 1.10 2008-04-01 16:40:37 francis Exp $
class UserInfoRequestSentAlert < ActiveRecord::Base
belongs_to :user