aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/general_controller.rb4
-rw-r--r--app/controllers/track_controller.rb43
-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
-rw-r--r--app/views/help/about.rhtml9
-rw-r--r--app/views/request/show.rhtml8
-rw-r--r--app/views/track/track_set.rhtml35
17 files changed, 206 insertions, 29 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 21450fddc..9b9e311e7 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: general_controller.rb,v 1.16 2008-04-01 05:43:40 francis Exp $
+# $Id: general_controller.rb,v 1.17 2008-04-01 16:40:37 francis Exp $
class GeneralController < ApplicationController
@@ -57,7 +57,7 @@ class GeneralController < ApplicationController
sortby = params[:sortby]
perform_search(query, sortby)
end
-
+
# For debugging
def fai_test
sleep 10
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
new file mode 100644
index 000000000..0ad3ae740
--- /dev/null
+++ b/app/controllers/track_controller.rb
@@ -0,0 +1,43 @@
+# app/controllers/track_controller.rb:
+# Publically visible email alerts and RSS - think an alert system crossed with
+# social bookmarking.
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: track_controller.rb,v 1.1 2008-04-01 16:40:37 francis Exp $
+
+class TrackController < ApplicationController
+
+ # Track all updates to a particular request
+ def track_request
+ @info_request = InfoRequest.find_by_url_title(params[:url_title])
+ @track_thing = TrackThing.create_track_for_request(@info_request)
+ if self.track_set
+ flash[:notice] = "You are now tracking this request!"
+ redirect_to request_url(@info_request)
+ end
+ end
+
+ # Generic request tracker - set @track_thing before calling
+ def track_set
+ @title = @track_thing.params[:title]
+ @track_thing.track_medium = params[:track_thing][:track_medium]
+
+ if not params[:submitted_track_request] or not @track_thing.valid?
+ render :template => 'track/track_set'
+ return false
+ end
+
+ if not authenticated?(@track_thing.params)
+ return false
+ end
+
+ @track_thing.tracking_user_id = @user.id
+ @track_thing.save!
+
+ return true
+ end
+
+end
+
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
diff --git a/app/views/help/about.rhtml b/app/views/help/about.rhtml
index 41bd84b60..39b7e7684 100644
--- a/app/views/help/about.rhtml
+++ b/app/views/help/about.rhtml
@@ -125,6 +125,15 @@ Therefore, we encourage you to use your real name, but you may use a pseudonym
if you would like to be anonymous.
</dd>
+<dt id="tracking">Why does the list of things that I'm tracking appear publically on the site?</dt>
+
+<dd>This helps you find others who are researching the same area of government,
+so you can form groups to investigate or campaign together. It also helps us
+show requests which are related to other requests. If you've ever used a
+"social bookmarking" website such as Delicious, Digg or reddit, think of it like
+that.
+</dd>
+
</dl>
<div id="hash_link_padding"></div>
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index 8e5ac5f4f..1bb926b57 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -66,6 +66,14 @@
</div>
<div id="request_sidebar">
+<!-- <h2>Actions</h2>
+
+ <p>
+ <%= link_to "Track updates to this request", track_request_url(:url_title => @info_request.url_title) %>
+ (by email or RSS)
+ </p>
+ -->
+
<% if @info_requests_same_user_same_body.size > 0 %>
<h2>Some other requests made by
<%= user_link(@info_request.user) %> to <%= public_body_link(@info_request.public_body) %></h2>
diff --git a/app/views/track/track_set.rhtml b/app/views/track/track_set.rhtml
new file mode 100644
index 000000000..380d1dd64
--- /dev/null
+++ b/app/views/track/track_set.rhtml
@@ -0,0 +1,35 @@
+<div id="track_set">
+
+<% form_tag({:id => "track_set_form"}) do %>
+ <%= foi_error_messages_for :track_thing %>
+
+ <div class="form_note">
+ <h1><%=@title %></h1>
+ </div>
+
+ <div class="form_note">
+ <!--<%= radio_button "track_thing", "track_medium", "email_immediate" %>
+ <label for="track_track_medium_email">Send me emails shortly after there are updates</label>
+ <br> -->
+ <%= radio_button "track_thing", "track_medium", "email_daily" %>
+ <label for="track_thing_track_medium_email">Send me emails at most once a day</label>
+ <!--
+ <br>
+ <%= radio_button "track_thing", "track_medium", "rss" %>
+ <label for="track__thingtrack_medium_rss">Give me a feed to use in my news reader (RSS)</label>
+ -->
+ </div>
+
+ <p class="form_note">
+ <strong>Privacy note:</strong> It will appear publically on your user page that
+ you are tracking this request (<a href="/help/about/#tracking">details</a>).
+ </p>
+
+ <div class="form_button">
+ <%= hidden_field_tag 'submitted_track_request', 1 %>
+ <%= submit_tag "Subscribe" %>
+ </div>
+<% end %>
+
+</div>
+