diff options
author | francis <francis> | 2008-01-29 01:26:21 +0000 |
---|---|---|
committer | francis <francis> | 2008-01-29 01:26:21 +0000 |
commit | de7f36c6e3c5f1739a60839fe6bf3e7d510e1225 (patch) | |
tree | 7b8d74dd4face7a0c9aeee2a510278f184f30655 | |
parent | 4cee79a9c722f5a9058f4d0e4390847f05aa2c3e (diff) |
First hack at new interface for classifying requests - is only per request, not
per message, and has more states.
-rw-r--r-- | app/controllers/request_controller.rb | 78 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 23 | ||||
-rw-r--r-- | app/models/info_request.rb | 93 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 4 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 4 | ||||
-rw-r--r-- | app/models/post_redirect.rb | 4 | ||||
-rw-r--r-- | app/models/public_body.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 5 | ||||
-rw-r--r-- | app/views/request/_classify.rhtml | 22 | ||||
-rw-r--r-- | app/views/request/_correspondence.rhtml | 9 | ||||
-rw-r--r-- | app/views/request/_describe_state.rhtml | 36 | ||||
-rw-r--r-- | app/views/request/_followup.rhtml | 4 | ||||
-rw-r--r-- | app/views/request/_request_listing.rhtml | 24 | ||||
-rw-r--r-- | app/views/request/describe_state.rhtml | 23 | ||||
-rw-r--r-- | app/views/request/show.rhtml | 38 | ||||
-rw-r--r-- | app/views/request/show_response.rhtml | 18 | ||||
-rw-r--r-- | config/routes.rb | 7 | ||||
-rw-r--r-- | db/migrate/027_change_classification_system.rb | 25 | ||||
-rw-r--r-- | db/schema.rb | 27 | ||||
-rw-r--r-- | public/stylesheets/main.css | 17 | ||||
-rw-r--r-- | todo.txt | 13 |
22 files changed, 315 insertions, 167 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index e317b5f48..945db8931 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.40 2008-01-22 13:48:16 francis Exp $ +# $Id: request_controller.rb,v 1.41 2008-01-29 01:26:21 francis Exp $ class RequestController < ApplicationController @@ -15,6 +15,7 @@ class RequestController < ApplicationController @status = @info_request.calculate_status @date_response_required_by = @info_request.date_response_required_by @collapse_quotes = params[:unfold] ? false : true + @is_owning_user = !authenticated_user.nil? && authenticated_user.id == @info_request.user_id end def list @@ -74,7 +75,54 @@ class RequestController < ApplicationController end end - # Show an individual incoming message + # Page describing state of message posts to + def describe_state + @info_request = InfoRequest.find(params[:id]) + if @info_request.described_last_incoming_message_id.nil? + @correspondences = @info_request.incoming_messages.find(:all) + else + @correspondences = @info_request.incoming_messages.find(:all, :conditions => "id > " + @info_request.described_last_incoming_message_id.to_s) + end + @correspondences.sort! { |a,b| a.sent_at <=> b.sent_at } + @is_owning_user = !authenticated_user.nil? && authenticated_user.id == @info_request.user_id + + if not @info_request.awaiting_description + flash[:notice] = "The status of this request is up to date." + if !params[:submitted_describe_state].nil? + flash[:notice] = "The status of this request was made up to date elsewhere while you were filling in the form." + end + redirect_to show_request_url(:id => @info_request) + return + end + + if !params[:submitted_describe_state].nil? + 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 + ".", + :email_subject => "Classify an FOI response from " + @info_request.public_body.name + ) + # do nothing - as "authenticated?" has done the redirect to signin page for us + return + end + + if !params[:incoming_message] + flash[:error] = "Please choose whether or not you got some of the information that you wanted." + return + end + + @info_request.awaiting_description = false + @info_request.described_last_incoming_message_id = @correspondences[-1].id # XXX lock this with InfoRequest.receive + @info_request.described_state = params[:incoming_message][:described_state] + @info_request.save! + flash[:notice] = "Thank you for answering!" + # XXX need to prompt for followups here + redirect_to show_request_url(:id => @info_request) + return + end + end + + + # Show an individual incoming message, and allow followup def show_response @incoming_message = IncomingMessage.find(params[:incoming_message_id]) @info_request = @incoming_message.info_request @@ -96,31 +144,7 @@ class RequestController < ApplicationController raise sprintf("Incoming message %d does not belong to request %d", @incoming_message.info_request_id, params[:id]) end - if !params[:submitted_classify].nil? - # Let the user classify it. - 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 + ".", - :email_subject => "Classify an FOI response from " + @info_request.public_body.name - ) - return - # do nothing - as "authenticated?" has done the redirect to signin page for us - end - - if !params[:incoming_message] - flash[:error] = "Please choose whether or not you got some of the information that you wanted." - render :action => 'show_response' - return - end - - contains_information = (params[:incoming_message][:contains_information] == 'true' ? true : false) - @incoming_message.contains_information = contains_information - @incoming_message.user_classified = true - @incoming_message.save! - flash[:notice] = "Thank you for classifying the response." - redirect_to show_request_url(:id => @info_request) - return - elsif !params[:submitted_followup].nil? + if !params[:submitted_followup].nil? # See if values were valid or not @outgoing_message.info_request = @info_request if !@outgoing_message.valid? diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 2d35e14f2..fcd73508e 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -1,16 +1,14 @@ # == Schema Information -# Schema version: 26 +# Schema version: 27 # # Table name: incoming_messages # -# id :integer not null, primary key -# 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), not null +# id :integer not null, primary key +# info_request_id :integer not null +# raw_data :text not null +# created_at :datetime not null +# updated_at :datetime not null +# is_bounce :boolean default(false), not null # # models/incoming_message.rb: @@ -20,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.36 2008-01-24 15:53:15 francis Exp $ +# $Id: incoming_message.rb,v 1.37 2008-01-29 01:26:21 francis Exp $ # TODO @@ -280,6 +278,11 @@ class IncomingMessage < ActiveRecord::Base return nil end end + + # Has message arrived "recently"? + def recently_arrived + (Time.now - self.created_at) <= 3.days + end end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 445682e1a..0207bca94 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -1,14 +1,17 @@ # == Schema Information -# Schema version: 26 +# Schema version: 27 # # Table name: info_requests # -# id :integer not null, primary key -# 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 +# id :integer not null, primary key +# 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 +# described_state :string(255) not null +# awaiting_description :boolean default(false), not null +# described_last_incoming_message_id :integer # # models/info_request.rb: @@ -17,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.29 2008-01-24 15:53:15 francis Exp $ +# $Id: info_request.rb,v 1.30 2008-01-29 01:26:21 francis Exp $ require 'digest/sha1' @@ -34,6 +37,17 @@ class InfoRequest < ActiveRecord::Base has_many :incoming_messages has_many :info_request_events + belongs_to :dsecribed_last_incoming_message_id + + # user described state + validates_inclusion_of :described_state, :in => [ + 'waiting_response', + 'waiting_clarification', + 'rejected', + 'successful', + 'partially_successful' + ] + public # Email which public body should use to respond to request. This is in # the format PREFIXrequest-ID-HASH@DOMAIN. Here ID is the id of the @@ -75,35 +89,28 @@ public # A new incoming email to this request def receive(email, raw_email, is_bounce) - incoming_message = IncomingMessage.new - incoming_message.raw_data = raw_email - incoming_message.is_bounce = is_bounce - incoming_message.info_request = self - incoming_message.save! + ActiveRecord::Base.transaction do + incoming_message = IncomingMessage.new + incoming_message.raw_data = raw_email + incoming_message.is_bounce = is_bounce + incoming_message.info_request = self + incoming_message.save! + + self.awaiting_description = true + self.save! + end RequestMailer.deliver_new_response(self, incoming_message) end # Work out what the situation of the request is - # awaiting - awaiting a response - # overdue - response is overdue - # information - has response containing information - # none - received a response, but no information XXX - # unknown - received a response that hasn't been classified + # waiting_response + # waiting_response_overdue # XXX calculated, should be cached for display? + # waiting_clarification + # rejected + # successful + # partially_successful def calculate_status - # Extract aggregate information for any incoming messages all together - contains_information = false - missing_classification = false - self.incoming_messages.each do |msg| - if msg.user_classified - if msg.contains_information - contains_information = true - end - else - missing_classification = true - end - end - # See if response would be overdue date_today = Time.now.strftime("%Y-%m-%d") date_response = date_response_required_by.strftime("%Y-%m-%d") @@ -113,22 +120,15 @@ public overdue = false end - # Return appropriate status string - if self.incoming_messages.size == 0 + if self.described_state == "waiting_response" if overdue - return "overdue" + return 'waiting_response_overdue' else - return "awaiting" + return 'waiting_response' end end - if missing_classification - return "unknown" - end - if contains_information - return "information" - else - return "none" - end + + return self.described_state end # Calculate date by which response is required by law. @@ -185,13 +185,6 @@ public return response_required_by end - # Return array of unclassified responses - def unclassified_responses - return self.incoming_messages.select do |msg| - not msg.user_classified - end - end - # Where the initial request is sent to def recipient_email if MySociety::Config.getbool("STAGING_SITE", 1) diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 320ebd7e8..0b5ac64f5 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 27 # # Table name: info_request_events # @@ -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.7 2008-01-24 15:53:15 francis Exp $ +# $Id: info_request_event.rb,v 1.8 2008-01-29 01:26:21 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 5010a6c2b..391308bd4 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 27 # # 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.23 2008-01-24 15:53:15 francis Exp $ +# $Id: outgoing_message.rb,v 1.24 2008-01-29 01:26:21 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 b468735de..864f2880f 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 27 # # 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.13 2008-01-24 15:53:15 francis Exp $ +# $Id: post_redirect.rb,v 1.14 2008-01-29 01:26:21 francis Exp $ require 'openssl' # for random bytes function diff --git a/app/models/public_body.rb b/app/models/public_body.rb index cc3d1d928..5e90ca9ec 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 27 # # 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.14 2008-01-24 15:53:15 francis Exp $ +# $Id: public_body.rb,v 1.15 2008-01-29 01:26:21 francis Exp $ class PublicBody < ActiveRecord::Base validates_presence_of :name diff --git a/app/models/user.rb b/app/models/user.rb index 31d6b43a3..13a57ec92 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 27 # # 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.22 2008-01-24 15:53:15 francis Exp $ +# $Id: user.rb,v 1.23 2008-01-29 01:26:21 francis Exp $ require 'digest/sha1' diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml index 394634470..1dd82dc6e 100644 --- a/app/views/admin_request/show.rhtml +++ b/app/views/admin_request/show.rhtml @@ -10,6 +10,7 @@ <strong>Public body:</strong> <%=h @info_request.public_body.name %> <br> <strong>Incoming email address:</strong> <%=h @info_request.incoming_email %> <br> <strong>Envelope email address:</strong> <%=h @info_request.envelope_email %> <br> +<strong>Described last incoming message id:</strong> <%=h @info_request.described_last_incoming_message_id.nil? ? "nil" : @info_request.described_last_incoming_message_id %> </p> <%= link_to 'Public page', main_url(request_url(@info_request)) %> @@ -18,6 +19,7 @@ <table> <tr> + <th>Id</th> <% for column in OutgoingMessage.content_columns %> <th><%= column.human_name %></th> <% end %> @@ -26,6 +28,7 @@ <% for outgoing_message in @info_request.outgoing_messages %> <tr class="<%= cycle('odd', 'even') %>"> + <td><%=h outgoing_message.id %></td> <% for column in OutgoingMessage.content_columns.map { |c| c.name } %> <td><%=h outgoing_message.send(column) %></td> <% end %> @@ -44,6 +47,7 @@ <table> <tr> + <th>Id</th> <% for column in IncomingMessage.content_columns %> <th><%= column.human_name %></th> <% end %> @@ -51,6 +55,7 @@ <% for incoming_message in @info_request.incoming_messages %> <tr class="<%= cycle('odd', 'even') %>"> + <td><%=h incoming_message.id %></td> <% for column in IncomingMessage.content_columns.map { |c| c.name } %> <td><%=h incoming_message.send(column) %></td> <% end %> diff --git a/app/views/request/_classify.rhtml b/app/views/request/_classify.rhtml deleted file mode 100644 index f48c53f3d..000000000 --- a/app/views/request/_classify.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -<% form_for(:incoming_message, @info_request) do |f| %> - <h2>Got what you wanted?</h2> - <p>Does this response contain any of the information that you requested?</p> - <p> - <%= radio_button "incoming_message", "contains_information", "true" %> - <label for="incoming_message_contains_information_true">Yes, this response contains some or all of the information that I requested.</label> - <br> - <%= radio_button "incoming_message", "contains_information", "false" %> - <label for="incoming_message_contains_information_false">No, this response does not contain any of the information.</label> - </p> - - <%= hidden_field_tag 'submitted_classify', 1 %> - <%= submit_tag "Update" %> - - <p> - <% if not @is_owning_user %> - (You will be asked to sign in as <%= user_link(@info_request.user) %>) - <% end %> - </p> - -<% end %> - diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml index 2f64d1246..6758bb189 100644 --- a/app/views/request/_correspondence.rhtml +++ b/app/views/request/_correspondence.rhtml @@ -11,17 +11,14 @@ <%= incoming_message.safe_mail_from %> of <% end %> <%= public_body_link(@info_request.public_body) %> - <% if incoming_message.contains_information %> - sent some <strong>useful information</strong> - <% elsif incoming_message.is_bounce %> + <% if incoming_message.is_bounce %> replied automatically <% else %> replied <% end %> on <strong><%= simple_date(incoming_message.sent_at) %></strong> - <% if not incoming_message.user_classified %> - — please <%= link_to "classify this response", show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) %> - <% end %> + (<%= link_to "link to this", show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) %>, + <%= link_to "reply", show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) + "#show_response_followup" %>) </p> <% elsif (correspondence.class.to_s == 'InfoRequestEvent') info_request_event = correspondence diff --git a/app/views/request/_describe_state.rhtml b/app/views/request/_describe_state.rhtml new file mode 100644 index 000000000..22336972f --- /dev/null +++ b/app/views/request/_describe_state.rhtml @@ -0,0 +1,36 @@ +<% if @is_owning_user %> + <% form_for(:incoming_message, @info_request, :url => describe_state_url(:id => @info_request.id)) do |f| %> + <h2>What are you doing about this request now?</h2> + <p>Filling this in each time you get a new response helps us track the progress of your request. + </p> + <p> + <%= radio_button "incoming_message", "described_state", "waiting_response" %> + <label for="incoming_message_described_state_waiting_response">I'm still <strong>waiting</strong> for a response</label> + <br> + <%= radio_button "incoming_message", "described_state", "waiting_clarification" %> + <label for="incoming_message_described_state_waiting_clarification">I'm about to <strong>clarify</strong> my request</label> + <br> + <%= radio_button "incoming_message", "described_state", "rejected" %> + <label for="incoming_message_described_state_rejected">My request has been <strong>rejected</strong></label> + <br> + <%= radio_button "incoming_message", "described_state", "successful" %> + <label for="incoming_message_described_state_successful">I've received (nearly) <strong>all the information</strong> that I asked for</label> + <br> + <%= radio_button "incoming_message", "described_state", "partially_successful" %> + <label for="incoming_message_described_state_partially_successful">I've received <strong>some of the information</strong> that I asked for</label> + </p> + + <%= hidden_field_tag 'submitted_describe_state', 1 %> + <%= submit_tag "Next >>" %> + <% end %> +<% else %> + We don't know whether the most recent response to this request contains + information or not + – + if you are + <%= user_link(@info_request.user) %>, + please + <%= link_to "sign in", signin_url(:r => request.request_uri) %> + and let everyone know. +<% end %> + diff --git a/app/views/request/_followup.rhtml b/app/views/request/_followup.rhtml index ef2f566fe..f228ca71d 100644 --- a/app/views/request/_followup.rhtml +++ b/app/views/request/_followup.rhtml @@ -9,8 +9,8 @@ <% end %> </h2> - <p>If the public body has asked for clarifications about your request, - you can respond to them here. + <p>Use this if the public body has asked for clarification of + your request. <% form_for(:outgoing_message, @outgoing_message) do |o| %> <p> diff --git a/app/views/request/_request_listing.rhtml b/app/views/request/_request_listing.rhtml index 7dcc38633..35300929e 100644 --- a/app/views/request/_request_listing.rhtml +++ b/app/views/request/_request_listing.rhtml @@ -1,14 +1,36 @@ <% for info_request in info_requests %> + <% status = info_request.calculate_status %> <p class="request_listing"> <%= request_link(info_request) %> + <br> <%=h excerpt(info_request.initial_request_text, "", 300) %> <br> <span class="request_listing_bottomline"> + <strong> + <% if info_request.awaiting_description %> + Awaiting classification. + <% elsif status == 'waiting_response' %> + Awaiting response. + <% elsif status == 'waiting_response_overdue' %> + Response overdue. + <% elsif status == 'partially_successful' %> + Partially successful. + <% elsif status == 'rejected' %> + Rejected. + <% elsif status == 'successful' %> + Successful. + <% elsif status == 'waiting_clarification' %> + Waiting clarification. + <% else %> + <% raise "unknown status " + status %> + <% end %> + </strong> + Requested from <%= public_body_link(info_request.public_body) %> by <%= user_link(info_request.user) %> - on <%= simple_date(info_request.created_at) %> + on <%= simple_date(info_request.created_at) %>. </span> </p> <% end %> diff --git a/app/views/request/describe_state.rhtml b/app/views/request/describe_state.rhtml new file mode 100644 index 000000000..4c3e9d006 --- /dev/null +++ b/app/views/request/describe_state.rhtml @@ -0,0 +1,23 @@ +<% @title = "New responses to '" + h(@info_request.title) + "'" %> + +<%= foi_error_messages_for :incoming_message, :outgoing_message %> + +<div id="describe_state_form"> + <%= render :partial => 'describe_state' %> +</div> + +<div id="show_response_view"> + <h2>New responses to your request '<%= request_link @info_request %>'</h2> + + <% for correspondence in @correspondences %> + <%= render :partial => 'correspondence', :locals => { :correspondence => correspondence } %> + <% end %> + + <div id="show_response_followup"> + <%= render :partial => 'followup', :locals => { :correspondence => @incoming_message } %> + </div> +</div> + +<div id="describe_state_form"> + <%= render :partial => 'describe_state' %> +</div> diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml index 6ab31321b..89726054c 100644 --- a/app/views/request/show.rhtml +++ b/app/views/request/show.rhtml @@ -1,5 +1,11 @@ <% @title = h(@info_request.title) %> +<% if @info_request.awaiting_description %> + <div id="describe_state_form"> + <%= render :partial => 'describe_state' %> + </div> +<% end %> + <div id="request_main"> <h1><%=@title%></h1> @@ -10,19 +16,28 @@ </p> <p id="request_status"> - <% if @status == 'awaiting' %> + <% if @info_request.awaiting_description %> + <% if @is_owning_user %> + Please <strong>answer the question above</strong> so we know whether the + most recent response you got contained useful information. + <% else %> + This request is <strong>awaiting description</strong> by <%= user_link(@info_request.user) %> + <% end %> + <% elsif @status == 'waiting_response' %> Currently <strong>waiting for a response</strong> from <%= public_body_link(@info_request.public_body) %>, due by <strong><%= simple_date(@date_response_required_by) %></strong>. - <% elsif @status == 'overdue' %> + <% elsif @status == 'waiting_response_overdue' %> Currently <strong>overdue a response</strong> from <%= public_body_link(@info_request.public_body) %>. The <%= link_to "response was due", about_url %></li> on <strong><%= simple_date(@date_response_required_by) %></strong>. - <% elsif @status == 'information' %> - The request was at least partly <strong>successful</strong>. - <% elsif @status == 'none' %> - The request is <strong>not (yet) successful</strong>. - <% elsif @status == 'unknown' %> + <% elsif @status == 'rejected' %> + The request was <strong>rejected</strong> by <%= public_body_link(@info_request.public_body) %>. + <% elsif @status == 'successful' %> + The request was <strong>successful</strong>. + <% elsif @status == 'partially_successful' %> + The request was <strong>partially successful</strong>. + <% elsif @status == 'waiting_clarification' %> <strong><%= MySociety::Format.fancy_pluralize(@info_request.incoming_messages.size, 'Response', 'responses') %> received</strong>, but <%= user_link(@info_request.user) %> has not yet reported whether @@ -30,9 +45,8 @@ contained useful information or not. If you are <%= user_link(@info_request.user) %>, please classify them below. - <!-- This will be useful here too: @info_request.unclassified_responses --> <% else %> - <% raise "unknown status " + $status %> + <% raise "unknown status " + @status %> <% end %> </p> @@ -51,4 +65,10 @@ <p>...--> </div> +<% if @info_request.awaiting_description %> + <div id="describe_state_form"> + <%= render :partial => 'describe_state' %> + </div> +<% end %> + diff --git a/app/views/request/show_response.rhtml b/app/views/request/show_response.rhtml index 98760440e..670dfb08f 100644 --- a/app/views/request/show_response.rhtml +++ b/app/views/request/show_response.rhtml @@ -1,9 +1,17 @@ -<% @title = "View and classify FOI response" %> +<% if @incoming_message.recently_arrived %> + <% @title = "New response to '" + h(@info_request.title) + "'" %> +<% else %> + <% @title = "Response to '" + h(@info_request.title) + "'" %> +<% end %> <%= foi_error_messages_for :incoming_message, :outgoing_message %> <div id="show_response_view"> - <h2>New response to your request '<%= request_link @info_request %>'</h2> + <% if @incoming_message.recently_arrived %> + <h2>New response to your request '<%= request_link @info_request %>'</h2> + <% else %> + <h2>Response to your request '<%= request_link @info_request %>'</h2> + <% end %> <%= render :partial => 'correspondence', :locals => { :correspondence => @incoming_message } %> @@ -12,9 +20,3 @@ </div> </div> -<% if not @incoming_message.user_classified %> - <div id="show_response_classify_action"> - <%= render :partial => 'classify' %> - <div> -<% end %> - diff --git a/config/routes.rb b/config/routes.rb index c54f68681..45401afd0 100644 --- a/config/routes.rb +++ b/config/routes.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: routes.rb,v 1.30 2008-01-22 18:34:17 francis Exp $ +# $Id: routes.rb,v 1.31 2008-01-29 01:26:22 francis Exp $ ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. @@ -17,9 +17,10 @@ ActionController::Routing::Routes.draw do |map| request.home '/', :action => 'frontpage' request.request_list '/list', :action => 'list' request.new_request '/new', :action => 'new' - request.show_request '/request/:id', :action => 'show' + request.show_request '/request/:id', :action => 'show' + request.describe_state '/request/:id/describe', :action => 'describe_state' request.show_response '/request/:id/response/:incoming_message_id', :action => 'show_response' - request.get_attachment '/request/:id/response/:incoming_message_id/attach/:part/*file_name', :action => 'get_attachment' + request.get_attachment '/request/:id/response/:incoming_message_id/attach/:part/*file_name', :action => 'get_attachment' end map.with_options :controller => 'user' do |user| diff --git a/db/migrate/027_change_classification_system.rb b/db/migrate/027_change_classification_system.rb new file mode 100644 index 000000000..d9e6ad844 --- /dev/null +++ b/db/migrate/027_change_classification_system.rb @@ -0,0 +1,25 @@ +class ChangeClassificationSystem < ActiveRecord::Migration + def self.up + remove_column :incoming_messages, :contains_information + remove_column :incoming_messages, :user_classified + + add_column :info_requests, :described_state, :string + InfoRequest.update_all "described_state = 'waiting_response'" + change_column :info_requests, :described_state, :string, :null => false + + add_column :info_requests, :awaiting_description, :boolean, :default => false, :null => false + InfoRequest.update_all "awaiting_description = 't' where (select count(*) from incoming_messages where info_request_id = info_requests.id) > 0" + + add_column :info_requests, :described_last_incoming_message_id, :integer + InfoRequest.update_all "described_last_incoming_message_id = null" + end + + def self.down + add_column :incoming_messages, :contains_information, :boolean + add_column :incoming_messages, :user_classified, :boolean + + remove_column :info_requests, :described_state + remove_column :info_requests, :awaiting_description + remove_column :info_requests, :described_last_incoming_message_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 3b1d6eb54..057a239b9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,16 +9,14 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 26) do +ActiveRecord::Schema.define(:version => 27) do create_table "incoming_messages", :force => true do |t| - 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, :null => 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 "is_bounce", :default => false, :null => false end create_table "info_request_events", :force => true do |t| @@ -29,11 +27,14 @@ ActiveRecord::Schema.define(:version => 26) do end create_table "info_requests", :force => true do |t| - 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 + 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 + t.string "described_state", :null => false + t.boolean "awaiting_description", :default => false, :null => false + t.integer "described_last_incoming_message_id" end create_table "outgoing_messages", :force => true do |t| diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index b793f50f2..f17f19354 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -298,15 +298,24 @@ table#list_requests .odd { display: none; } -/* /show_response - viewing and classifying individual responses */ +/* /describe_state - user setting status of request */ -#show_response_classify_action { - float: left; +#describe_state_form { + clear: both; + background-color: #eeffee; + border: solid 1px #00cc00; + padding: 1em; +} + +/* /show_response - viewing individual responses */ + +#show_response_sidebar { + float: right; width: 30%; } #show_response_view { - float: right; + float: left; width: 70%; } #show_response_followup { @@ -1,3 +1,8 @@ + +search for 'classify' and tidy text +hack storing better info so know when state changed for stats purpose +go through each one and add on the extra stuff + FOI requests to use to test it ============================== @@ -133,10 +138,11 @@ eived from server "/data/vhost/foi.mysociety.org/docs/dispatch.fcgi" Show public body email address on their public page, with a link to say "this isn't right!" Email me updates on this request +Requests with related content Blog posts / Wikipedia articles about this request -About page Contact page +Finish about page Remember me box This can't possible be the best way, it is too depressing: @@ -151,7 +157,7 @@ http://www.ico.gov.uk/Home/tools_and_resources/decision_notices.aspx (10:32:52) Matthew: their function is called autogrow_textarea() by the way, if you just want to look at it... thanks :) I won't do it now as there are more important things, I was just accidentally impressed -Lucene for search (ask Louise for plugin) +Lucene for search - use http://acts-as-solr.rubyforge.org/ Have a look at http://swish-e.org/ Generic alerting/tracking system including @@ -216,6 +222,9 @@ the last > converted to > too badly Check log rotation is working well +Ask what they learnt from request, and other things? + and reward by putting their request on front page + Sources of public bodies ======================== |