diff options
-rw-r--r-- | app/models/incoming_message.rb | 16 | ||||
-rw-r--r-- | app/models/info_request.rb | 14 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 12 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 16 | ||||
-rw-r--r-- | app/models/post_redirect.rb | 22 | ||||
-rw-r--r-- | app/models/public_body.rb | 20 | ||||
-rw-r--r-- | app/models/user.rb | 18 | ||||
-rw-r--r-- | db/migrate/026_add_many_null_constraints.rb | 103 | ||||
-rw-r--r-- | db/schema.rb | 84 | ||||
-rw-r--r-- | spec/models/public_body_spec.rb | 6 | ||||
-rw-r--r-- | todo.txt | 11 |
11 files changed, 221 insertions, 101 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 23e513508..2d35e14f2 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -1,16 +1,16 @@ # == Schema Information -# Schema version: 25 +# Schema version: 26 # # Table name: incoming_messages # # id :integer not null, primary key -# info_request_id :integer -# raw_data :text -# created_at :datetime -# updated_at :datetime -# user_classified :boolean default(false) +# info_request_id :integer not null +# raw_data :text not null +# created_at :datetime not null +# updated_at :datetime not null +# user_classified :boolean default(false), not null # contains_information :boolean -# is_bounce :boolean default(false) +# is_bounce :boolean default(false), not null # # models/incoming_message.rb: @@ -20,7 +20,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.35 2008-01-23 01:59:23 francis Exp $ +# $Id: incoming_message.rb,v 1.36 2008-01-24 15:53:15 francis Exp $ # TODO diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 6f7c5d6d3..445682e1a 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -1,14 +1,14 @@ # == Schema Information -# Schema version: 25 +# Schema version: 26 # # Table name: info_requests # # id :integer not null, primary key -# title :text -# user_id :integer -# public_body_id :integer -# created_at :datetime -# updated_at :datetime +# title :text not null +# user_id :integer not null +# public_body_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null # # models/info_request.rb: @@ -17,7 +17,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.28 2008-01-21 10:20:34 francis Exp $ +# $Id: info_request.rb,v 1.29 2008-01-24 15:53:15 francis Exp $ require 'digest/sha1' diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 9e4d8f6b9..320ebd7e8 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -1,13 +1,13 @@ # == Schema Information -# Schema version: 25 +# Schema version: 26 # # Table name: info_request_events # # id :integer not null, primary key -# info_request_id :integer -# event_type :text -# params_yaml :text -# created_at :datetime +# info_request_id :integer not null +# event_type :text not null +# params_yaml :text not null +# created_at :datetime not null # # models/info_request_event.rb: @@ -15,7 +15,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.6 2008-01-21 11:08:16 francis Exp $ +# $Id: info_request_event.rb,v 1.7 2008-01-24 15:53:15 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 9eacab767..5010a6c2b 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -1,15 +1,15 @@ # == Schema Information -# Schema version: 25 +# Schema version: 26 # # Table name: outgoing_messages # # id :integer not null, primary key -# info_request_id :integer -# body :text -# status :string(255) -# message_type :string(255) -# created_at :datetime -# updated_at :datetime +# info_request_id :integer not null +# body :text not null +# status :string(255) not null +# message_type :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null # last_sent_at :datetime # incoming_message_followup_id :integer # @@ -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.22 2008-01-21 10:20:34 francis Exp $ +# $Id: outgoing_message.rb,v 1.23 2008-01-24 15:53:15 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 9a8b06439..b468735de 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -1,27 +1,31 @@ # == Schema Information -# Schema version: 25 +# Schema version: 26 # # Table name: post_redirects # # id :integer not null, primary key -# token :text -# uri :text +# token :text not null +# uri :text not null # post_params_yaml :text -# created_at :datetime -# updated_at :datetime -# email_token :text +# created_at :datetime not null +# updated_at :datetime not null +# email_token :text not null # reason_params_yaml :text # user_id :integer # # models/post_redirect.rb: -# Saves an HTTP POST request, so it can be redirected to later. -# For example, after registering / logging in. +# Saves an HTTP request, so it can be redirected to later. For example, after +# registering / logging in. This can save POST requests, if post_params_yaml +# is not null. +# +# See check_in_post_redirect in controllers/application.rb for the hack that +# fakes the redirect to include POST parameters in request later. # # 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.12 2008-01-14 19:11:18 francis Exp $ +# $Id: post_redirect.rb,v 1.13 2008-01-24 15:53:15 francis Exp $ require 'openssl' # for random bytes function diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 99b829b0f..cc3d1d928 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -1,18 +1,18 @@ # == Schema Information -# Schema version: 25 +# Schema version: 26 # # Table name: public_bodies # # id :integer not null, primary key -# name :text -# short_name :text -# request_email :text +# name :text not null +# short_name :text not null +# request_email :text not null # complaint_email :text -# version :integer -# last_edit_editor :string(255) -# last_edit_comment :string(255) -# created_at :datetime -# updated_at :datetime +# version :integer not null +# last_edit_editor :string(255) not null +# last_edit_comment :text not null +# created_at :datetime not null +# updated_at :datetime not null # # models/public_body.rb: @@ -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.13 2008-01-10 01:13:28 francis Exp $ +# $Id: public_body.rb,v 1.14 2008-01-24 15:53:15 francis Exp $ class PublicBody < ActiveRecord::Base validates_presence_of :name diff --git a/app/models/user.rb b/app/models/user.rb index cc2ca88ab..31d6b43a3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,16 +1,16 @@ # == Schema Information -# Schema version: 25 +# Schema version: 26 # # Table name: users # # id :integer not null, primary key -# email :string(255) default("ook") -# name :string(255) -# hashed_password :string(255) -# salt :string(255) -# created_at :datetime -# updated_at :datetime -# email_confirmed :boolean default(false) +# email :string(255) not null +# name :string(255) not null +# hashed_password :string(255) not null +# salt :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# email_confirmed :boolean default(false), not null # # models/user.rb: @@ -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.21 2008-01-23 01:59:23 francis Exp $ +# $Id: user.rb,v 1.22 2008-01-24 15:53:15 francis Exp $ require 'digest/sha1' diff --git a/db/migrate/026_add_many_null_constraints.rb b/db/migrate/026_add_many_null_constraints.rb new file mode 100644 index 000000000..7abd2e8f2 --- /dev/null +++ b/db/migrate/026_add_many_null_constraints.rb @@ -0,0 +1,103 @@ +class AddManyNullConstraints < ActiveRecord::Migration + def self.up + change_column :users, :email, :string, :null => false + change_column :users, :name, :string, :null => false + change_column :users, :hashed_password, :string, :null => false + change_column :users, :salt, :string, :null => false + change_column :users, :created_at, :datetime, :null => false + change_column :users, :updated_at, :datetime, :null => false + change_column :users, :email_confirmed, :boolean, :null => false, :default =>false + + change_column :public_bodies, :name, :text, :null => false + change_column :public_bodies, :short_name, :text, :null => false + change_column :public_bodies, :request_email, :text, :null => false + change_column :public_bodies, :version, :integer, :null => false + change_column :public_bodies, :last_edit_editor, :string, :null => false + change_column :public_bodies, :last_edit_comment, :text, :null => false + change_column :public_bodies, :created_at, :datetime, :null => false + change_column :public_bodies, :updated_at, :datetime, :null => false + + change_column :post_redirects, :token, :text, :null => false + change_column :post_redirects, :uri, :text, :null => false + change_column :post_redirects, :created_at, :datetime, :null => false + change_column :post_redirects, :updated_at, :datetime, :null => false + change_column :post_redirects, :email_token, :text, :null => false + + change_column :outgoing_messages, :info_request_id, :integer, :null => false + change_column :outgoing_messages, :body, :text, :null => false + change_column :outgoing_messages, :status, :string, :null => false + change_column :outgoing_messages, :message_type, :string, :null => false + change_column :outgoing_messages, :created_at, :datetime, :null => false + change_column :outgoing_messages, :updated_at, :datetime, :null => false + + change_column :info_requests, :title, :text, :null => false + change_column :info_requests, :user_id, :integer, :null => false + change_column :info_requests, :public_body_id, :integer, :null => false + change_column :info_requests, :created_at, :datetime, :null => false + change_column :info_requests, :updated_at, :datetime, :null => false + + change_column :info_request_events, :info_request_id, :integer, :null => false + change_column :info_request_events, :event_type, :text, :null => false + change_column :info_request_events, :params_yaml, :text, :null => false + change_column :info_request_events, :created_at, :datetime, :null => false + + change_column :incoming_messages, :info_request_id, :integer, :null => false + change_column :incoming_messages, :raw_data, :text, :null => false + change_column :incoming_messages, :created_at, :datetime, :null => false + change_column :incoming_messages, :updated_at, :datetime, :null => false + change_column :incoming_messages, :user_classified, :boolean, :null => false, :default => false + change_column :incoming_messages, :is_bounce, :boolean, :null => false, :default => false + + end + + def self.down + change_column :users, :email, :string, :null => true + change_column :users, :name, :string, :null => true + change_column :users, :hashed_password, :string, :null => true + change_column :users, :salt, :string, :null => true + change_column :users, :created_at, :datetime, :null => true + change_column :users, :updated_at, :datetime, :null => true + change_column :users, :email_confirmed, :boolean, :null => true, :default =>false + + change_column :public_bodies, :name, :text, :null => true + change_column :public_bodies, :short_name, :text, :null => true + change_column :public_bodies, :request_email, :text, :null => true + change_column :public_bodies, :version, :integer, :null => true + change_column :public_bodies, :last_edit_editor, :string, :null => true + change_column :public_bodies, :last_edit_comment, :string, :null => true + change_column :public_bodies, :created_at, :datetime, :null => true + change_column :public_bodies, :updated_at, :datetime, :null => true + + change_column :post_redirects, :token, :text, :null => true + change_column :post_redirects, :uri, :text, :null => true + change_column :post_redirects, :created_at, :datetime, :null => true + change_column :post_redirects, :updated_at, :datetime, :null => true + change_column :post_redirects, :email_token, :text, :null => true + + change_column :outgoing_messages, :info_request_id, :integer, :null => true + change_column :outgoing_messages, :body, :text, :null => true + change_column :outgoing_messages, :status, :string, :null => true + change_column :outgoing_messages, :message_type, :string, :null => true + change_column :outgoing_messages, :created_at, :datetime, :null => true + change_column :outgoing_messages, :updated_at, :datetime, :null => true + + change_column :info_requests, :title, :text, :null => true + change_column :info_requests, :user_id, :integer, :null => true + change_column :info_requests, :public_body_id, :integer, :null => true + change_column :info_requests, :created_at, :datetime, :null => true + change_column :info_requests, :updated_at, :datetime, :null => true + + change_column :info_request_events, :info_request_id, :integer, :null => true + change_column :info_request_events, :event_type, :text, :null => true + change_column :info_request_events, :params_yaml, :text, :null => true + change_column :info_request_events, :created_at, :datetime, :null => true + + change_column :incoming_messages, :info_request_id, :integer, :null => true + change_column :incoming_messages, :raw_data, :text, :null => true + change_column :incoming_messages, :created_at, :datetime, :null => true + change_column :incoming_messages, :updated_at, :datetime, :null => true + change_column :incoming_messages, :user_classified, :boolean, :null => true, :default => false + change_column :incoming_messages, :is_bounce, :boolean, :null => true, :default => false + + end +end diff --git a/db/schema.rb b/db/schema.rb index 9bbf81145..3b1d6eb54 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,65 +9,65 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 25) do +ActiveRecord::Schema.define(:version => 26) do create_table "incoming_messages", :force => true do |t| - t.integer "info_request_id" - t.text "raw_data" - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "user_classified", :default => false + t.integer "info_request_id", :null => false + t.text "raw_data", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "user_classified", :default => false, :null => false t.boolean "contains_information" - t.boolean "is_bounce", :default => false + t.boolean "is_bounce", :default => false, :null => false end create_table "info_request_events", :force => true do |t| - t.integer "info_request_id" - t.text "event_type" - t.text "params_yaml" - t.datetime "created_at" + t.integer "info_request_id", :null => false + t.text "event_type", :null => false + t.text "params_yaml", :null => false + t.datetime "created_at", :null => false end create_table "info_requests", :force => true do |t| - t.text "title" - t.integer "user_id" - t.integer "public_body_id" - t.datetime "created_at" - t.datetime "updated_at" + t.text "title", :null => false + t.integer "user_id", :null => false + t.integer "public_body_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "outgoing_messages", :force => true do |t| - t.integer "info_request_id" - t.text "body" - t.string "status" - t.string "message_type" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "info_request_id", :null => false + t.text "body", :null => false + t.string "status", :null => false + t.string "message_type", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.datetime "last_sent_at" t.integer "incoming_message_followup_id" end create_table "post_redirects", :force => true do |t| - t.text "token" - t.text "uri" + t.text "token", :null => false + t.text "uri", :null => false t.text "post_params_yaml" - t.datetime "created_at" - t.datetime "updated_at" - t.text "email_token" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "email_token", :null => false t.text "reason_params_yaml" t.integer "user_id" end create_table "public_bodies", :force => true do |t| - t.text "name" - t.text "short_name" - t.text "request_email" + t.text "name", :null => false + t.text "short_name", :null => false + t.text "request_email", :null => false t.text "complaint_email" - t.integer "version" - t.string "last_edit_editor" - t.string "last_edit_comment" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "version", :null => false + t.string "last_edit_editor", :null => false + t.text "last_edit_comment", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "public_body_versions", :force => true do |t| @@ -93,13 +93,13 @@ ActiveRecord::Schema.define(:version => 25) do add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" create_table "users", :force => true do |t| - t.string "email" - t.string "name" - t.string "hashed_password" - t.string "salt" - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "email_confirmed", :default => false + t.string "email", :null => false + t.string "name", :null => false + t.string "hashed_password", :null => false + t.string "salt", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "email_confirmed", :default => false, :null => false end end diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index bb9b70682..bd403dcd1 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -14,6 +14,8 @@ describe PublicBody, " when saving" do @public_body.short_name = "TPB" @public_body.request_email = "requestBOOlocalhost" @public_body.complaint_email = "complaint@localhost" + @public_body.last_edit_editor = "*test*" + @public_body.last_edit_comment = "This is a test" lambda { @public_body.save! }.should raise_error(ActiveRecord::RecordInvalid) end @@ -22,6 +24,8 @@ describe PublicBody, " when saving" do @public_body.short_name = "TPB" @public_body.request_email = "request@localhost" @public_body.complaint_email = "complaintBOOlocalhost" + @public_body.last_edit_editor = "*test*" + @public_body.last_edit_comment = "This is a test" lambda { @public_body.save! }.should raise_error(ActiveRecord::RecordInvalid) end @@ -30,6 +34,8 @@ describe PublicBody, " when saving" do @public_body.short_name = "TPB" @public_body.request_email = "request@localhost" @public_body.complaint_email = "complaint@localhost" + @public_body.last_edit_editor = "*test*" + @public_body.last_edit_comment = "This is a test" @public_body.save! end end @@ -25,13 +25,20 @@ user interface, e.g. search results, RSS feeds. - Awaiting response - Response overdue - Awaiting follow up information / clarification from requester - (same as awaiting categorisation from requester?) - Responses contain no useful information XXX exact wording matters - Responses contain some useful information (XXX RSS needs to know when more) - Response contains all information requested +Flag: awaiting categorisation from requester? State to ask about individual messages +Are you now: + * Awaiting a response + * About to clarify your request + * Looking at a rejection + * Happy with your response + * Partially happy with your response + Please choose what this response is. a) an acknowledgement of message received / forwarded on b) asking for clarification about your request @@ -96,7 +103,6 @@ Link internally between different bits of admin interface Add SQL database indexes to token / email_token in post_redirects -Set "null" and "default" options more in schema Add SQL foreign keys to database schema (THIS IS IMPORTANT, or things will screw up) execute 'ALTER TABLE researchers ADD CONSTRAINT fk_researchers_departments FOREIGN KEY ( department_id ) REFERENCES departments( id ) ' http://wiki.rubyonrails.org/rails/pages/UsingMigrations link to: @@ -104,6 +110,7 @@ Add SQL foreign keys to database schema (THIS IS IMPORTANT, or things will screw http://www.redhillconsulting.com.au/rails_plugins.html#foreign_key_migrations http://rubyforge.org/projects/mig-constraints/ Call "delete from sessions where now() - updated_at > 3600" (one hour) or whatever +Also delete old post_redirects (and similar) Mark some requests as test requests |