aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/views/admin_public_body/list.rhtml8
-rw-r--r--app/views/admin_public_body/show.rhtml15
-rw-r--r--db/migrate/010_remove_public_body_id_from_outgoing_messages.rb2
-rw-r--r--db/migrate/011_add_created_updated_fields.rb36
-rw-r--r--db/schema.rb9
-rw-r--r--todo.txt8
6 files changed, 64 insertions, 14 deletions
diff --git a/app/views/admin_public_body/list.rhtml b/app/views/admin_public_body/list.rhtml
index 35fc755bd..f932c2236 100644
--- a/app/views/admin_public_body/list.rhtml
+++ b/app/views/admin_public_body/list.rhtml
@@ -9,12 +9,10 @@
<% for public_body in @public_bodies %>
<tr class="<%= cycle('odd', 'even') %>">
- <% for column in PublicBody.content_columns %>
- <td><%=h public_body.send(column.name) %></td>
+ <td><%= link_to public_body.name, :action => 'show', :id => public_body %></td>
+ <% for column in PublicBody.content_columns.map { |c| c.name } - [ "name" ] %>
+ <td><%=h public_body.send(column) %></td>
<% end %>
- <td><%= link_to 'Show', :action => 'show', :id => public_body %></td>
- <td><%= link_to 'Edit', :action => 'edit', :id => public_body %></td>
- <td><%= link_to 'Destroy', { :action => 'destroy', :id => public_body }, :confirm => 'Are you sure?', :method => :post %></td>
</tr>
<% end %>
</table>
diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml
index dfe10b7f1..bc8abd890 100644
--- a/app/views/admin_public_body/show.rhtml
+++ b/app/views/admin_public_body/show.rhtml
@@ -13,21 +13,24 @@
<h2>History</h2>
<table border="1">
<tr>
-<% for column in PublicBody.content_columns %>
+<%
+ history_columns = PublicBody.content_columns
+ history_columns.delete_if {|c| ['created_at', 'updated_at'].include?(c.name)}
+ for column in history_columns %>
<th><%= column.human_name %></th>
<% end %>
<th>Updated at</th>
</tr>
-<% for old_public_body in @public_body.versions.reverse %>
+<% for historic_public_body in @public_body.versions.reverse %>
<tr class="<%= cycle('odd', 'even') %>">
- <% for column in PublicBody.content_columns %>
+ <% for column in history_columns %>
<% # Highlight entries which have changed since previous version
- changed = ((old_public_body.send(column.name) != @public_body.versions[old_public_body.version - 2].send(column.name)) && column.name != 'version' && column.name != 'last_edit_editor' && column.name != 'last_edit_comment') || (old_public_body.version == 1) %>
+ changed = (not ['version', 'last_edit_editor', 'last_edit_comment'].include?(column.name)) && ((historic_public_body.send(column.name) != @public_body.versions[historic_public_body.version - 2].send(column.name)) || (historic_public_body.version == 1)) %>
<td <%= changed ? ' class="entry_changed" ': '' %> >
- <%=h old_public_body.send(column.name) %>
+ <%=h historic_public_body.send(column.name) %>
</td>
<% end %>
- <td><%=h old_public_body.updated_at %></td>
+ <td><%=h historic_public_body.updated_at %></td>
</tr>
<% end %>
</table>
diff --git a/db/migrate/010_remove_public_body_id_from_outgoing_messages.rb b/db/migrate/010_remove_public_body_id_from_outgoing_messages.rb
index d39cb4e70..da5ffc87e 100644
--- a/db/migrate/010_remove_public_body_id_from_outgoing_messages.rb
+++ b/db/migrate/010_remove_public_body_id_from_outgoing_messages.rb
@@ -4,6 +4,6 @@ class RemovePublicBodyIdFromOutgoingMessages < ActiveRecord::Migration
end
def self.down
- add_column :ourgoing_messages, :public_body_id, :integer
+ add_column :outgoing_messages, :public_body_id, :integer
end
end
diff --git a/db/migrate/011_add_created_updated_fields.rb b/db/migrate/011_add_created_updated_fields.rb
new file mode 100644
index 000000000..47bb27b78
--- /dev/null
+++ b/db/migrate/011_add_created_updated_fields.rb
@@ -0,0 +1,36 @@
+class AddCreatedUpdatedFields < ActiveRecord::Migration
+ def self.up
+ # InfoRequest
+ add_column :info_requests, :created_at, :datetime
+ add_column :info_requests, :updated_at, :datetime
+
+ # Outgoing Message already has it
+
+ # PublicBody
+ add_column :public_bodies, :created_at, :datetime
+ add_column :public_bodies, :updated_at, :datetime
+
+ # PublicBodyVersion doesn't need it
+
+ # Session
+ add_column :sessions, :created_at, :datetime
+
+ # Users
+ add_column :users, :created_at, :datetime
+ add_column :users, :updated_at, :datetime
+
+ end
+
+ def self.down
+ remove_column :info_requests, :created_at
+ remove_column :info_requests, :updated_at
+
+ remove_column :public_bodies, :created_at
+ remove_column :public_bodies, :updated_at
+
+ remove_column :sessions, :created_at
+
+ remove_column :users, :created_at
+ remove_column :users, :updated_at
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e3fdbce13..04f4a49fd 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2,12 +2,14 @@
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
-ActiveRecord::Schema.define(:version => 10) do
+ActiveRecord::Schema.define(:version => 11) do
create_table "info_requests", :force => true do |t|
t.column "title", :text
t.column "user_id", :integer
t.column "public_body_id", :integer
+ t.column "created_at", :datetime
+ t.column "updated_at", :datetime
end
create_table "outgoing_messages", :force => true do |t|
@@ -27,6 +29,8 @@ ActiveRecord::Schema.define(:version => 10) do
t.column "version", :integer
t.column "last_edit_editor", :string
t.column "last_edit_comment", :string
+ t.column "created_at", :datetime
+ t.column "updated_at", :datetime
end
create_table "public_body_versions", :force => true do |t|
@@ -45,6 +49,7 @@ ActiveRecord::Schema.define(:version => 10) do
t.column "session_id", :string
t.column "data", :text
t.column "updated_at", :datetime
+ t.column "created_at", :datetime
end
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
@@ -55,6 +60,8 @@ ActiveRecord::Schema.define(:version => 10) do
t.column "name", :string
t.column "hashed_password", :string
t.column "salt", :string
+ t.column "created_at", :datetime
+ t.column "updated_at", :datetime
end
end
diff --git a/todo.txt b/todo.txt
index b58771c04..a5bff0b3e 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,11 +1,12 @@
Give a better login dialog
Check validation for saving info request / outgoing message pair works with transactions fine
+Set "null" and "default" options more in schema
Tidy up error message text (like "body must be filled in" on info request form)
-Add created_at / updated_at to every model that might need it
Make sure that constraints / foreign keys in model are in same order as data in schema
Check have validates_presence_of for every belongs_to
Check using :string rather than :text for definitely limited fields like "status"
+
Redirect the front page to the new FOI request page
Make it say "dear" as default letter
@@ -16,6 +17,11 @@ Tidying
Rename "file_request" controller to "new" ?
Add SQL foreign keys to database schema
+ 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:
+ http://www.surfdewey.com/2.html
+ 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
Later