aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/info_request.rb45
-rw-r--r--app/models/info_request_event.rb11
-rw-r--r--app/views/admin_request/show.rhtml6
-rw-r--r--todo.txt8
4 files changed, 54 insertions, 16 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 346600bc6..09d9840bc 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.37 2008-02-14 09:55:21 francis Exp $
+# $Id: info_request.rb,v 1.38 2008-02-14 11:19:42 francis Exp $
require 'digest/sha1'
@@ -38,7 +38,7 @@ class InfoRequest < ActiveRecord::Base
belongs_to :dsecribed_last_incoming_message_id
- # user described state
+ # user described state (also update in info_request_event)
validates_inclusion_of :described_state, :in => [
'waiting_response',
'waiting_clarification',
@@ -171,17 +171,38 @@ public
# XXX how do we cope with case where extra info was required from the requester
# by the public body in order to fulfill the request, as per sections 1(3) and 10(6b) ?
def date_response_required_by
- # We use the last_sent_at date for each outgoing message, as fair
- # enough if the first email bounced or something and it got recent.
- # XXX if a second outgoing message is really a new request, then this
- # is no good. Likewise, a second outgoing message may contain
- # clarifications asked for by the public body, and so reset things.
- # Possibly just show 20 working days since the *last* message? Hmmm.
- earliest_sent = self.outgoing_messages.map { |om| om.last_sent_at }.min
- if earliest_sent.nil?
- raise "internal error, minimum last_sent_at for outgoing_messages is nil for request " + self.id.to_s + " outgoing messages count " + self.outgoing_messages.size.to_s
+ events = self.info_request_events.find(:all, :order => "created_at")
+
+ # Find the earliest time at which an outgoing message was:
+ # -- sent at all
+ # -- OR the same message was resent
+ # -- OR the public body requested clarification, and a follow up was sent
+ earliest = nil
+ expecting_clarification = false
+ events.each do |event|
+ if [ 'sent', 'resent', 'followup_sent' ].include?(event.event_type)
+ outgoing_message = OutgoingMessage.find(event.params[:outgoing_message_id])
+
+ if earliest.nil?
+ earliest = outgoing_message
+ elsif event.event_type == 'resent' and outgoing_message.id == event.params[:outgoing_message_id]
+ earliest = outgoing_message
+ elsif expecting_clarification and event.event_type == 'followup_sent'
+ earliest = outgoing_message
+ expecting_clarification = false;
+ end
+ end
+
+ if event.described_state == 'waiting_clarification'
+ expecting_clarification = true
+ end
+ end
+ if earliest.nil?
+ raise "internal error, date_response_required_by gets nil for request " + self.id.to_s + " outgoing messages count " + self.outgoing_messages.size.to_s
end
+ earliest_sent = earliest.last_sent_at
+ # Count forward 20 working days
days_passed = 0
response_required_by = earliest_sent
while days_passed < 20
@@ -212,8 +233,6 @@ public
end
end
- # XXX and give until the end of that 20th working day
-
return response_required_by
end
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 528d728a7..fe26212fd 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -16,7 +16,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.11 2008-02-07 15:11:16 francis Exp $
+# $Id: info_request_event.rb,v 1.12 2008-02-14 11:19:42 francis Exp $
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
@@ -32,6 +32,15 @@ class InfoRequestEvent < ActiveRecord::Base
'response'
]
+ # user described state (also update in info_request)
+ validates_inclusion_of :described_state, :in => [
+ 'waiting_response',
+ 'waiting_clarification',
+ 'rejected',
+ 'successful',
+ 'partially_successful'
+ ]
+
# We store YAML version of parameters in the database
def params=(params)
self.params_yaml = params.to_yaml
diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml
index e950c4349..690d85905 100644
--- a/app/views/admin_request/show.rhtml
+++ b/app/views/admin_request/show.rhtml
@@ -26,7 +26,7 @@
<th>Actions</th>
</tr>
-<% for outgoing_message in @info_request.outgoing_messages %>
+<% for outgoing_message in @info_request.outgoing_messages.find(:all, :order => 'created_at') %>
<tr class="<%= cycle('odd', 'even') %>">
<td><%=h outgoing_message.id %></td>
<% for column in OutgoingMessage.content_columns.map { |c| c.name } %>
@@ -53,7 +53,7 @@
<% end %>
</tr>
-<% for incoming_message in @info_request.incoming_messages %>
+<% for incoming_message in @info_request.incoming_messages.find(:all, :order => 'created_at') %>
<tr class="<%= cycle('odd', 'even') %>">
<td><%=h incoming_message.id %></td>
<% for column in IncomingMessage.content_columns.map { |c| c.name } %>
@@ -68,6 +68,7 @@
<table>
<tr>
+ <th>Id</th>
<% for column in InfoRequestEvent.content_columns %>
<th><%= column.human_name %></th>
<% end %>
@@ -75,6 +76,7 @@
<% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %>
<tr class="<%= cycle('odd', 'even') %>">
+ <td><%=h info_request_event.id %></td>
<% for column in InfoRequestEvent.content_columns.map { |c| c.name } %>
<td><%=h info_request_event.send(column) %></td>
<% end %>
diff --git a/todo.txt b/todo.txt
index 82959ef70..9255c302c 100644
--- a/todo.txt
+++ b/todo.txt
@@ -54,6 +54,10 @@ or maybe 'response refusing to publish for spurious reasons
Next
====
+Check "From:" of requests and followups, it is coming out as GovernmentSpy rather than the user
+
+Change ..@.. to something prettier / less confusing
+Put the admin "Public page" link on request page somewhere clearer
Lucene for search - use http://acts-as-solr.rubyforge.org/
Have a look at http://swish-e.org/
@@ -66,6 +70,10 @@ sort orders we need)
Later
=====
+Make the email address for responses
+ - something bland for domain name
+ - perhaps put name of user in the part before the @ ?
+
Make interface to specify status
Synthesise these tips into our handful of snappy snappy bullet points