diff options
author | francis <francis> | 2008-02-06 12:20:36 +0000 |
---|---|---|
committer | francis <francis> | 2008-02-06 12:20:36 +0000 |
commit | 3f68ca08f0d814558288e58ccadea3b333354051 (patch) | |
tree | 3003f25fc7b9f942b3566767809dc067a05ce906 | |
parent | f7b020796a743877e24295423527e448111ec065 (diff) |
Links to user admin page and public body admin page from request admin page
-rw-r--r-- | app/controllers/admin_request_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 22 | ||||
-rw-r--r-- | app/helpers/link_to_helper.rb | 30 | ||||
-rw-r--r-- | app/models/info_request.rb | 15 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 3 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 4 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 3 | ||||
-rw-r--r-- | app/views/admin_user/list.rhtml | 2 | ||||
-rw-r--r-- | app/views/admin_user/show.rhtml | 2 | ||||
-rw-r--r-- | todo.txt | 8 |
10 files changed, 65 insertions, 30 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 79705a8aa..a6146fc9c 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: admin_request_controller.rb,v 1.3 2008-01-22 18:34:15 francis Exp $ +# $Id: admin_request_controller.rb,v 1.4 2008-02-06 12:20:37 francis Exp $ class AdminRequestController < ApplicationController layout "admin" @@ -26,7 +26,7 @@ class AdminRequestController < ApplicationController @outgoing_message = OutgoingMessage.find(params[:outgoing_message_id]) @outgoing_message.resend_message flash[:notice] = "Outgoing message resent" - redirect_to admin_url('request/show/' + @outgoing_message.info_request.id.to_s) + redirect_to request_admin_url(@outgoing_message.info_request) end def edit_outgoing @@ -39,7 +39,7 @@ class AdminRequestController < ApplicationController if @outgoing_message.update_attributes(params[:outgoing_message]) @outgoing_message.info_request.log_event("edit_outgoing", { :outgoing_message_id => @outgoing_message.id, :editor => admin_http_auth_user(), :old_body => old_body, :body => @outgoing_message.body }) flash[:notice] = 'OutgoingMessage was successfully updated.' - redirect_to admin_url('request/show/' + @outgoing_message.info_request.id.to_s) + redirect_to request_admin_url(@outgoing_message.info_request) else render :action => 'edit_outgoing' end diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index cdb84434b..fb9a75cc2 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_controller.rb,v 1.44 2008-02-06 09:41:43 francis Exp $ +# $Id: request_controller.rb,v 1.45 2008-02-06 12:20:37 francis Exp $ class RequestController < ApplicationController @@ -78,7 +78,7 @@ class RequestController < ApplicationController end end - # Page describing state of message posts to + # Describing state of messages post here def describe_state @info_request = InfoRequest.find(params[:id]) @@ -104,6 +104,8 @@ class RequestController < ApplicationController end if !params[:submitted_describe_state].nil? + # Check authenticated, and parameters set + if not authenticated_as_user?(@info_request.user, :web => "To classify the response to this FOI request", :email => "Then you can classify the FOI response you have got from " + @info_request.public_body.name + ".", @@ -123,15 +125,10 @@ class RequestController < ApplicationController return end - ActiveRecord::Base.transaction do - @info_request.awaiting_description = false - last_event = InfoRequestEvent.find(@last_info_request_event_id) - last_event.described_state = params[:incoming_message][:described_state] - @info_request.described_state = params[:incoming_message][:described_state] - last_event.save! - @info_request.save! - end + # Make the state change + @info_request.set_described_state(params[:incoming_message][:described_state], @last_info_request_event_id) + # Display appropriate next page (e.g. help for complaint etc.) if @info_request.described_state == 'waiting_response' flash[:notice] = "<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get a response before the end of <strong>" + simple_date(@info_request.date_response_required_by) + "</strong>.</p>" redirect_to show_request_url(:id => @info_request) @@ -149,11 +146,14 @@ class RequestController < ApplicationController redirect_to show_request_url(:id => @info_request) elsif @info_request.described_state == 'waiting_clarification' flash[:notice] = "Please write your follow up message containing the necessary clarifications below." - redirect_to show_response_url(:id => @info_request.id, :incoming_message_id => @events_needing_description[-1].id) + redirect_to show_response_url(:id => @info_request.id, :incoming_message_id => @events_needing_description[-1].params[:incoming_message_id]) else raise "unknown described_state " + @info_request.described_state end return + else + # Display default template + return end end diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 5c7242d18..3e5294fbc 100644 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -5,21 +5,27 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: link_to_helper.rb,v 1.13 2008-01-30 09:53:47 francis Exp $ +# $Id: link_to_helper.rb,v 1.14 2008-02-06 12:20:37 francis Exp $ module LinkToHelper # Links to various models - # XXX consolidate with simplify_url_part in controllers/application.rb so - # ones with calls to simplify_url_part are only in one place + # Requests def request_url(info_request) return show_request_url(:id => info_request, :only_path => true) end def request_link(info_request) link_to h(info_request.title), request_url(info_request) end - + def request_admin_url(info_request) + return admin_url('request/show/' + info_request.id.to_s) + end + def request_admin_link(info_request) + link_to h(info_request.title), request_admin_url(info_request) + end + + # Public bodies def public_body_url(public_body) return show_public_body_url(:simple_short_name => simplify_url_part(public_body.short_name), :only_path => true) end @@ -29,7 +35,17 @@ module LinkToHelper def public_body_link(public_body) link_to h(public_body.name), public_body_url(public_body) end + def public_body_admin_url(public_body) + return admin_url('body/show/' + public_body.id.to_s) + end + def public_body_admin_link(public_body) + link_to h(public_body.name), public_body_admin_url(public_body) + end + def public_body_admin_link_short(public_body) + link_to h(public_body.short_name), public_body_admin_url(public_body) + end + # Users def user_url(user) return show_user_url(:simple_name => simplify_url_part(user.name)) end @@ -50,6 +66,12 @@ module LinkToHelper link_to h(user.name), user_url(user) end end + def user_admin_url(user) + return admin_url('user/show/' + user.id.to_s) + end + def user_admin_link(user) + link_to h(user.name), user_admin_url(user) + end def info_request_link(info_request) diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 68ace338a..d5c95b8ee 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.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: info_request.rb,v 1.34 2008-02-06 09:41:44 francis Exp $ +# $Id: info_request.rb,v 1.35 2008-02-06 12:20:37 francis Exp $ require 'digest/sha1' @@ -110,6 +110,19 @@ public RequestMailer.deliver_new_response(self, incoming_message) end + # Change status - event id is of the most recent event at the change + # XXX should probably check event id is last event here + def set_described_state(new_state, event_id) + ActiveRecord::Base.transaction do + self.awaiting_description = false + last_event = InfoRequestEvent.find(event_id) + last_event.described_state = new_state + self.described_state = new_state + last_event.save! + self.save! + end + end + # Work out what the situation of the request is # waiting_response # waiting_response_overdue # XXX calculated, should be cached for display? diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 544ca87bc..9d6c7d3d0 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.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: outgoing_message.rb,v 1.25 2008-02-06 09:41:44 francis Exp $ +# $Id: outgoing_message.rb,v 1.26 2008-02-06 12:20:37 francis Exp $ class OutgoingMessage < ActiveRecord::Base belongs_to :info_request @@ -90,6 +90,7 @@ class OutgoingMessage < ActiveRecord::Base self.status = 'sent' self.save! self.info_request.log_event('followup_' + log_event_type, { :email => self.info_request.recipient_email, :outgoing_message_id => self.id }) + self.info_request.set_described_state('waiting_response', self.info_request.events_needing_description[-1].id) else raise "Message id #{self.id} has type '#{self.message_type}' which send_message can't handle" end diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index 747d8ae46..138cb4ea4 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_mailer.rb,v 1.19 2008-01-21 11:08:16 francis Exp $ +# $Id: request_mailer.rb,v 1.20 2008-02-06 12:20:37 francis Exp $ class RequestMailer < ApplicationMailer def initial_request(info_request, outgoing_message) @@ -35,7 +35,7 @@ class RequestMailer < ApplicationMailer def new_response(info_request, incoming_message) post_redirect = PostRedirect.new( - :uri => show_response_url(:id => info_request.id, :incoming_message_id => incoming_message.id), + :uri => describe_state_url(:id => info_request.id), :user_id => info_request.user.id) post_redirect.save! url = confirm_url(:email_token => post_redirect.email_token) diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml index 769235fb4..0453e4ce8 100644 --- a/app/views/admin_request/show.rhtml +++ b/app/views/admin_request/show.rhtml @@ -7,7 +7,8 @@ <strong><%= column.human_name %>:</strong> <%=h @info_request.send(column.name) %> <br/> <% end %> -<strong>Public body:</strong> <%=h @info_request.public_body.name %> <br> +<strong>Created by:</strong> <%= user_admin_link(@info_request.user) %> <br> +<strong>Public body:</strong> <%= public_body_admin_link(@info_request.public_body) %> <br> <strong>Incoming email address:</strong> <%=h @info_request.incoming_email %> <br> <strong>Envelope email address:</strong> <%=h @info_request.envelope_email %> <br> </p> diff --git a/app/views/admin_user/list.rhtml b/app/views/admin_user/list.rhtml index b65b640e4..969caa765 100644 --- a/app/views/admin_user/list.rhtml +++ b/app/views/admin_user/list.rhtml @@ -4,7 +4,7 @@ <table> <tr> - <th>ID</th> + <th>Id</th> <% for column in ['Name', 'Email', 'Created at', 'Updated at', 'Email confirmed'] %> <th><%= column %></th> <% end %> diff --git a/app/views/admin_user/show.rhtml b/app/views/admin_user/show.rhtml index 70f4b1840..7dbc5377a 100644 --- a/app/views/admin_user/show.rhtml +++ b/app/views/admin_user/show.rhtml @@ -3,7 +3,7 @@ <h1><%=@title%></h1> <p> -<strong>ID:</strong> <%= @admin_user.id%> +<strong>Id:</strong> <%= @admin_user.id%> <br> <% for column in User.content_columns %> <strong><%= column.human_name %>:</strong> <% if column.name == 'email' %> @@ -1,8 +1,3 @@ -we change the state when a follow up is sent - -events_needing_description.size in views wrong -check goes to describe URL from email - FOI requests to use to test it ============================== @@ -25,6 +20,9 @@ BAILII - relationship with law courts, robots.txt ? Status of messages stuff ======================== +events_needing_description.size in views wrong +check goes to describe URL from email + Add - response was made in private state or maybe 'response refusing to publish for spurious reasons |