aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.rb4
-rw-r--r--app/models/outgoing_message.rb4
-rw-r--r--app/models/post_redirect.rb4
-rw-r--r--app/models/public_body.rb27
-rw-r--r--app/models/public_body_tag.rb26
-rw-r--r--app/models/user.rb4
-rw-r--r--app/models/user_info_request_sent_alert.rb13
-rw-r--r--app/views/admin_public_body/_form.rhtml3
-rw-r--r--app/views/admin_public_body/show.rhtml2
-rw-r--r--db/migrate/036_add_public_body_tags.rb17
-rw-r--r--db/schema.rb10
-rw-r--r--todo.txt16
15 files changed, 122 insertions, 20 deletions
diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb
index 4e4f1fcd7..c04e6c448 100644
--- a/app/models/contact_validator.rb
+++ b/app/models/contact_validator.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 34
+# Schema version: 36
#
# 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.2 2008-02-21 20:45:51 francis Exp $
+# $Id: contact_validator.rb,v 1.3 2008-02-26 15:13:51 francis Exp $
class ContactValidator < ActiveRecord::BaseWithoutTable
column :name, :string
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 27698d1a8..7908f21e7 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 34
+# Schema version: 36
#
# Table name: incoming_messages
#
@@ -18,7 +18,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.44 2008-02-25 00:39:27 francis Exp $
+# $Id: incoming_message.rb,v 1.45 2008-02-26 15:13:51 francis Exp $
# TODO
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 48ccedcc1..3ea3b59cc 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 34
+# Schema version: 36
#
# Table name: info_requests
#
@@ -20,7 +20,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.45 2008-02-22 01:58:36 francis Exp $
+# $Id: info_request.rb,v 1.46 2008-02-26 15:13:51 francis Exp $
require 'digest/sha1'
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 599e46e82..7ba8a1f16 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 34
+# Schema version: 36
#
# Table name: info_request_events
#
@@ -16,7 +16,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.17 2008-02-21 20:45:51 francis Exp $
+# $Id: info_request_event.rb,v 1.18 2008-02-26 15:13:51 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 9c76bc03f..eaaf9d636 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 34
+# Schema version: 36
#
# 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.30 2008-02-25 11:17:29 francis Exp $
+# $Id: outgoing_message.rb,v 1.31 2008-02-26 15:13:51 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 40a5034ea..f81e9b2b8 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 34
+# Schema version: 36
#
# Table name: post_redirects
#
@@ -25,7 +25,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.18 2008-02-21 20:45:51 francis Exp $
+# $Id: post_redirect.rb,v 1.19 2008-02-26 15:13:51 francis Exp $
require 'openssl' # for random bytes function
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 9a364f009..5fdcb85e3 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 34
+# Schema version: 36
#
# 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.20 2008-02-21 20:45:51 francis Exp $
+# $Id: public_body.rb,v 1.21 2008-02-26 15:13:51 francis Exp $
class PublicBody < ActiveRecord::Base
validates_presence_of :name
@@ -29,6 +29,7 @@ class PublicBody < ActiveRecord::Base
validates_presence_of :request_email
has_many :info_requests
+ has_many :public_body_tags
#acts_as_solr :fields => [:name, :short_name]
@@ -45,4 +46,26 @@ class PublicBody < ActiveRecord::Base
acts_as_versioned
self.non_versioned_columns << 'created_at' << 'updated_at'
+
+ # Given an input string of tags, sets all tags to that string
+ def tag_string=(tag_string)
+ tags = tag_string.split(/\s+/).uniq
+
+ ActiveRecord::Base.transaction do
+ for public_body_tag in self.public_body_tags
+ public_body_tag.destroy
+ end
+ for tag in tags
+ self.public_body_tags << PublicBodyTag.new(:name => tag)
+ end
+ end
+ end
+
+ def tag_string
+ return self.public_body_tags.map { |t| t.name }.join(' ')
+ end
+
+ def self.find_by_tag(tag)
+ return PublicBodyTag.find(:all, :conditions => ['name = ?', tag] ).map { |t| t.public_body }
+ end
end
diff --git a/app/models/public_body_tag.rb b/app/models/public_body_tag.rb
new file mode 100644
index 000000000..9224c5299
--- /dev/null
+++ b/app/models/public_body_tag.rb
@@ -0,0 +1,26 @@
+# == Schema Information
+# Schema version: 36
+#
+# Table name: public_body_tags
+#
+# id :integer not null, primary key
+# public_body_id :integer not null
+# name :text not null
+# created_at :datetime not null
+#
+
+# models/public_body_tag.rb:
+# Categories for public bodies.
+#
+# 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.1 2008-02-26 15:13:51 francis Exp $
+
+class PublicBodyTag < ActiveRecord::Base
+ validates_presence_of :public_body
+ validates_presence_of :name
+
+ belongs_to :public_body
+end
+
diff --git a/app/models/user.rb b/app/models/user.rb
index 1fa71dffb..ab680dc1e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,5 +1,5 @@
# == Schema Information
-# Schema version: 34
+# Schema version: 36
#
# Table name: users
#
@@ -19,7 +19,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.28 2008-02-22 01:58:36 francis Exp $
+# $Id: user.rb,v 1.29 2008-02-26 15:13:51 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 8a272d274..b00b67e78 100644
--- a/app/models/user_info_request_sent_alert.rb
+++ b/app/models/user_info_request_sent_alert.rb
@@ -1,3 +1,14 @@
+# == Schema Information
+# Schema version: 36
+#
+# Table name: user_info_request_sent_alerts
+#
+# id :integer not null, primary key
+# user_id :integer not null
+# info_request_id :integer not null
+# alert_type :string(255) not null
+#
+
# models/user_info_request_sent_alert.rb:
# Whether an alert has been sent to this user for this info_request, for a
# given type of alert.
@@ -5,7 +16,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.1 2008-02-22 01:58:36 francis Exp $
+# $Id: user_info_request_sent_alert.rb,v 1.2 2008-02-26 15:13:51 francis Exp $
class UserInfoRequestSentAlert < ActiveRecord::Base
belongs_to :user
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
index 8b9eca34e..0d4bf650a 100644
--- a/app/views/admin_public_body/_form.rhtml
+++ b/app/views/admin_public_body/_form.rhtml
@@ -5,6 +5,9 @@
<%= text_field 'public_body', 'name', :size => 60 %></p>
<p><label for="public_body_short_name">Short name</label><br/>
<%= text_field 'public_body', 'short_name', :size => 60 %></p>
+<p><label for="public_body_tag_string">Tags</label><br/>
+<%= text_field 'public_body', 'tag_string', :size => 40 %></p>
+
<p><label for="public_body_request_email">Request email</label><br/>
<%= text_field 'public_body', 'request_email', :size => 40 %></p>
diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml
index ae8ae2774..70182d123 100644
--- a/app/views/admin_public_body/show.rhtml
+++ b/app/views/admin_public_body/show.rhtml
@@ -7,6 +7,8 @@
<b><%= column.human_name %>:</b> <%=h @public_body.send(column.name) %>
<br/>
<% end %>
+<b>Tags:</b> <%=h @public_body.tag_string %>
+<br/>
</p>
<p><%= link_to 'Edit', '../edit/' + @public_body.id.to_s %>
diff --git a/db/migrate/036_add_public_body_tags.rb b/db/migrate/036_add_public_body_tags.rb
new file mode 100644
index 000000000..fc64b7576
--- /dev/null
+++ b/db/migrate/036_add_public_body_tags.rb
@@ -0,0 +1,17 @@
+class AddPublicBodyTags < ActiveRecord::Migration
+ def self.up
+ create_table :public_body_tags do |t|
+ t.column :public_body_id, :integer, :null => false
+ t.column :name, :text, :null => false
+ t.column :created_at, :datetime, :null => false
+ end
+
+ execute "ALTER TABLE public_body_tags ADD CONSTRAINT fk_public_body_tags_public_body FOREIGN KEY (public_body_id) REFERENCES public_bodies(id)"
+ add_index :public_body_tags, [:public_body_id, :name], :unique => true
+ end
+
+ def self.down
+ drop_table :public_body_tags
+ end
+end
+
diff --git a/db/schema.rb b/db/schema.rb
index a247262dc..c2d826b92 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 35) do
+ActiveRecord::Schema.define(:version => 36) do
create_table "incoming_messages", :force => true do |t|
t.integer "info_request_id", :null => false
@@ -79,6 +79,14 @@ ActiveRecord::Schema.define(:version => 35) do
t.datetime "updated_at", :null => false
end
+ create_table "public_body_tags", :force => true do |t|
+ t.integer "public_body_id", :null => false
+ t.text "name", :null => false
+ t.datetime "created_at", :null => false
+ end
+
+ add_index "public_body_tags", ["public_body_id", "name"], :name => "index_public_body_tags_on_public_body_id_and_name", :unique => true
+
create_table "public_body_versions", :force => true do |t|
t.integer "public_body_id"
t.integer "version"
diff --git a/todo.txt b/todo.txt
index 9f55ae4d3..9a94f6f03 100644
--- a/todo.txt
+++ b/todo.txt
@@ -34,9 +34,23 @@ Fix the fastcgi errors
[Mon Jan 21 10:38:45 2008] [error] [client 81.107.40.81] FastCGI: incomplete headers (0 bytes) rec
eived from server "/data/vhost/foi.mysociety.org/docs/dispatch.fcgi"
+Add tagging for public bodies
+
Later
=====
+Add lots more UNIQUE indices
+
+Merge workflow into one stream - find information, if you can't find it then request it.
+ so just search is on front page, with popular stuff below a la Google Directory
+
+Link to WriteToThem in sidebar of request - according to level of Government
+send to appropriate representative?
+Start a petition about this request
+Share this request on Facebook
+
+Successful requests should have success date as date in search results.
+
Tell application developer if working days table not up to date, and needs
updating
@@ -96,8 +110,6 @@ http://www.rcfp.org/foi_letter/generate.php
This is interesting
http://www.liverpool.gov.uk/Council_government_and_democracy/About_your_council/Data_protection_and_FOI/FOI/Suppliers_and_Contractors/index.asp
-Add spelling checker as in WTT
-
For grey hints in input fields
http://pauldowman.com/projects/fieldhints/