diff options
-rw-r--r-- | app/controllers/admin_public_body_controller.rb | 110 | ||||
-rw-r--r-- | app/controllers/application.rb | 14 | ||||
-rw-r--r-- | app/views/admin_public_body/_form.rhtml | 3 | ||||
-rw-r--r-- | db/migrate/007_add_public_body_editor_notes.rb | 15 | ||||
-rw-r--r-- | db/schema.rb | 30 | ||||
-rw-r--r-- | todo.txt | 1 |
6 files changed, 106 insertions, 67 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index 5f462a2ba..1dc679b31 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -4,58 +4,64 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: admin_public_body_controller.rb,v 1.2 2007-09-03 09:39:20 francis Exp $ +# $Id: admin_public_body_controller.rb,v 1.3 2007-09-03 13:52:01 francis Exp $ class AdminPublicBodyController < ApplicationController - layout "admin" - - def index - list - render :action => 'list' - end - - # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) - verify :method => :post, :only => [ :destroy, :create, :update ], - :redirect_to => { :action => :list } - - def list - @public_body_pages, @public_bodies = paginate :public_bodies, :per_page => 10 - end - - def show - @public_body = PublicBody.find(params[:id]) - end - - def new - @public_body = PublicBody.new - end - - def create - @public_body = PublicBody.new(params[:public_body]) - if @public_body.save - flash[:notice] = 'PublicBody was successfully created.' - redirect_to :action => 'list' - else - render :action => 'new' - end - end - - def edit - @public_body = PublicBody.find(params[:id]) - end - - def update - @public_body = PublicBody.find(params[:id]) - if @public_body.update_attributes(params[:public_body]) - flash[:notice] = 'PublicBody was successfully updated.' - redirect_to :action => 'show', :id => @public_body - else - render :action => 'edit' - end - end - - def destroy - PublicBody.find(params[:id]).destroy - redirect_to :action => 'list' - end + layout "admin" + + def index + list + render :action => 'list' + end + + # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) + verify :method => :post, :only => [ :destroy, :create, :update ], + :redirect_to => { :action => :list } + + def list + @public_body_pages, @public_bodies = paginate :public_bodies, :per_page => 10 + end + + def show + @public_body = PublicBody.find(params[:id]) + end + + def new + @public_body = PublicBody.new + end + + def create + params[:public_body][:last_edit_editor] = admin_http_auth_user() + @public_body = PublicBody.new(params[:public_body]) + if @public_body.save + flash[:notice] = 'PublicBody was successfully created.' + redirect_to :action => 'list' + else + render :action => 'new' + end + end + + def edit + @public_body = PublicBody.find(params[:id]) + @public_body.last_edit_comment = "" + end + + def update + params[:public_body][:last_edit_editor] = admin_http_auth_user() + @public_body = PublicBody.find(params[:id]) + if @public_body.update_attributes(params[:public_body]) + flash[:notice] = 'PublicBody was successfully updated.' + redirect_to :action => 'show', :id => @public_body + else + render :action => 'edit' + end + end + + def destroy + PublicBody.find(params[:id]).destroy + redirect_to :action => 'list' + end + + private + end diff --git a/app/controllers/application.rb b/app/controllers/application.rb index ddd6e86b4..f00479bee 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: application.rb,v 1.4 2007-08-04 11:10:25 francis Exp $ +# $Id: application.rb,v 1.5 2007-09-03 13:52:01 francis Exp $ class ApplicationController < ActionController::Base @@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_foi_session_id' + # Login form def signin if request.post? user = User.authenticate(params[:email], params[:password]) @@ -29,6 +30,7 @@ class ApplicationController < ActionController::Base end end + # Logout form def signout sessions[:user] = nil redirect_to frontpage @@ -36,6 +38,7 @@ class ApplicationController < ActionController::Base private + # Check the user is logged in def check_authentication unless session[:user] session[:intended_action] = action_name @@ -44,4 +47,13 @@ class ApplicationController < ActionController::Base end end + # For administration interface, return display name of authenticated user + def admin_http_auth_user + if not request.env["REMOTE_USER"] + return "*unknown*"; + else + return request.env["REMOTE_USER"] + end + end + end diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml index e088ef5c2..44d4f2c05 100644 --- a/app/views/admin_public_body/_form.rhtml +++ b/app/views/admin_public_body/_form.rhtml @@ -11,5 +11,8 @@ <p><label for="public_body_complaint_email">Complaint email</label><br/> <%= text_field 'public_body', 'complaint_email', :size => 40 %></p> + +<p><label for="public_body_last_edit_comment">Edit cOmment</label><br/> +<%= text_area 'public_body', 'last_edit_comment', :rows => 3, :cols => 60 %></p> <!--[eoform:public_body]--> diff --git a/db/migrate/007_add_public_body_editor_notes.rb b/db/migrate/007_add_public_body_editor_notes.rb new file mode 100644 index 000000000..7500ee649 --- /dev/null +++ b/db/migrate/007_add_public_body_editor_notes.rb @@ -0,0 +1,15 @@ +class AddPublicBodyEditorNotes < ActiveRecord::Migration + def self.up + add_column :public_bodies, :last_edit_editor, :string + add_column :public_bodies, :last_edit_comment, :string + add_column :public_body_versions, :last_edit_editor, :string + add_column :public_body_versions, :last_edit_comment, :string + end + + def self.down + remove_column :public_bodies, :last_edit_editor + remove_column :public_bodies, :last_edit_comment + remove_column :public_body_versions, :last_edit_editor + remove_column :public_body_versions, :last_edit_comment + end +end diff --git a/db/schema.rb b/db/schema.rb index 46802bf9a..8d159eae6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,7 +2,7 @@ # migrations feature of ActiveRecord to incrementally modify your database, and # then regenerate this schema definition. -ActiveRecord::Schema.define(:version => 6) do +ActiveRecord::Schema.define(:version => 7) do create_table "info_requests", :force => true do |t| t.column "title", :text @@ -10,21 +10,25 @@ ActiveRecord::Schema.define(:version => 6) do end create_table "public_bodies", :force => true do |t| - t.column "name", :text - t.column "short_name", :text - t.column "request_email", :text - t.column "complaint_email", :text - t.column "version", :integer + t.column "name", :text + t.column "short_name", :text + t.column "request_email", :text + t.column "complaint_email", :text + t.column "version", :integer + t.column "last_edit_editor", :string + t.column "last_edit_comment", :string end create_table "public_body_versions", :force => true do |t| - t.column "public_body_id", :integer - t.column "version", :integer - t.column "name", :text - t.column "short_name", :text - t.column "request_email", :text - t.column "complaint_email", :text - t.column "updated_at", :datetime + t.column "public_body_id", :integer + t.column "version", :integer + t.column "name", :text + t.column "short_name", :text + t.column "request_email", :text + t.column "complaint_email", :text + t.column "updated_at", :datetime + t.column "last_edit_editor", :string + t.column "last_edit_comment", :string end create_table "sessions", :force => true do |t| @@ -5,7 +5,6 @@ Fix up how we do HTML 4.0 Public body ----------- -Log user who made change to public body Display history of public body in admin |