Skip to content

Commit

Permalink
As a first attempt, in a dumb way, factor out jurisdiction-specific s…
Browse files Browse the repository at this point in the history
…tates to themes
  • Loading branch information
sebbacon committed Jul 7, 2011
1 parent f1e5ca3 commit 35e4ffd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 31 deletions.
14 changes: 6 additions & 8 deletions app/controllers/request_controller.rb
Expand Up @@ -52,6 +52,7 @@ def show
)
end


@last_info_request_event_id = @info_request.last_event_id_needing_description
@new_responses_count = @info_request.events_needing_description.select {|i| i.event_type == 'response'}.size
1
Expand Down Expand Up @@ -368,7 +369,6 @@ def describe_state
end
return
end

# Display advice for requester on what to do next, as appropriate
if @info_request.calculate_status == 'waiting_response'
flash[:notice] = _("<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get a response promptly, and normally before the end of <strong>
Expand Down Expand Up @@ -407,12 +407,6 @@ def describe_state
redirect_to respond_to_last_url(@info_request)
elsif @info_request.calculate_status == 'gone_postal'
redirect_to respond_to_last_url(@info_request) + "?gone_postal=1"
elsif @info_request.calculate_status == 'deadline_extended'
flash[:notice] = _("Authority has requested extension of the deadline.")
redirect_to unhappy_url(@info_request)
elsif @info_request.calculate_status == 'wrong_response'
flash[:notice] = _("Oh no! Sorry to hear that your request was wrong. Here is what to do now.")
redirect_to unhappy_url(@info_request)
elsif @info_request.calculate_status == 'internal_review'
flash[:notice] = _("<p>Thank you! Hopefully your wait isn't too long.</p><p>You should get a response within 20 days, or be told if it will take longer (<a href=\"%s\">details</a>).</p>") % [unhappy_url(@info_request) + "#internal_review"]
redirect_to request_url(@info_request)
Expand All @@ -426,7 +420,11 @@ def describe_state
flash[:notice] = _("If you have not done so already, please write a message below telling the authority that you have withdrawn your request. Otherwise they will not know it has been withdrawn.")
redirect_to respond_to_last_url(@info_request)
else
raise "unknown calculate_status " + @info_request.calculate_status
begin
return theme_describe_state(@info_request)
rescue NoMethodError
raise "unknown calculate_status " + @info_request.calculate_status
end
end
end

Expand Down
20 changes: 14 additions & 6 deletions app/models/info_request.rb
Expand Up @@ -51,14 +51,12 @@ class InfoRequest < ActiveRecord::Base
has_many :exim_logs, :order => 'exim_log_done_id'

has_tag_string

# user described state (also update in info_request_event, admin_request/edit.rhtml)
validates_inclusion_of :described_state, :in => [
def self.enumerate_states
states = [
'waiting_response',
'waiting_clarification',
'gone_postal',
'deadline_extended',
'wrong_response',
'not_held',
'rejected', # this is called 'refused' in UK FOI law and the user interface, but 'rejected' internally for historic reasons
'successful',
Expand All @@ -67,7 +65,16 @@ class InfoRequest < ActiveRecord::Base
'error_message',
'requires_admin',
'user_withdrawn'
]
]
begin
states += theme_extra_states
rescue NoMethodError
states
end
end

# user described state (also update in info_request_event, admin_request/edit.rhtml)
validates_inclusion_of :described_state, :in => InfoRequest.enumerate_states

validates_inclusion_of :prominence, :in => [
'normal',
Expand All @@ -94,6 +101,7 @@ class InfoRequest < ActiveRecord::Base
'blackhole' # just dump them
]


# only check on create, so existing models with mixed case are allowed
def validate_on_create
if !self.title.nil? && !MySociety::Validate.uses_mixed_capitals(self.title, 10)
Expand Down
1 change: 1 addition & 0 deletions app/views/general/_custom_state_descriptions.rhtml
@@ -0,0 +1 @@
<% raise "unknown status " + status %>
Empty file.
Empty file.
16 changes: 7 additions & 9 deletions app/views/request/_describe_state.rhtml
Expand Up @@ -4,7 +4,7 @@
<h2><%= _('What best describes the status of this request now?') %></h2>

<hr> <!------------------------------------------------>

<h3>This request is still in progress:</h3>
<% if @info_request.described_state != 'internal_review' %>
<div>
<%= radio_button "incoming_message", "described_state", "waiting_response", :id => 'waiting_response' + id_suffix %>
Expand Down Expand Up @@ -38,11 +38,10 @@
<label for="gone_postal<%=id_suffix%>"><%= _('They are going to reply <strong>by post</strong>') %></label>
</div>

<div>
<%= radio_button "incoming_message", "described_state", "deadline_extended", :id => 'deadline_extended' + id_suffix %>
<label for="deadline_extended<%=id_suffix%>"><%= _('Authority has requested <strong>extension of the deadline.</strong>') %></label>
</div>
<%= render :partial => 'general/custom_state_transitions_pending', :locals => {:id_suffix => id_suffix } %>

<hr> <!------------------------------------------------>
<h3>This particular request is finished:</h3>

<% if @info_request.described_state == 'internal_review' %>
<p><%= _('The <strong>review has finished</strong> and overall:') %></p>
Expand All @@ -65,12 +64,11 @@
<label for="rejected<%=id_suffix%>"><%= _('My request has been <strong>refused</strong>') %></label>
</div>

<div>
<%= radio_button "incoming_message", "described_state", "wrong_response", :id => 'wrong_response' + id_suffix %>
<label for="rejected<%=id_suffix%>"><%= _('Authority has replied but the response <strong>does not correspond to the request</strong>') %></label>
</div>
<%= render :partial => 'general/custom_state_transitions_complete', :locals => {:id_suffix => id_suffix } %>


<hr> <!------------------------------------------------>
<h3>Other:</h3>

<div>
<%= radio_button "incoming_message", "described_state", "error_message", :id => 'error_message' + id_suffix %>
Expand Down
7 changes: 6 additions & 1 deletion app/views/request/_other_describe_state.rhtml
Expand Up @@ -7,7 +7,7 @@
Thanks.') %></h2>

<hr> <!------------------------------------------------>

<h3>This request is still in progress:</h3>
<% if @info_request.described_state != 'internal_review' %>
<div>
<%= radio_button "incoming_message", "described_state", "waiting_response", :id => 'waiting_response' + id_suffix %>
Expand All @@ -34,7 +34,10 @@
<label for="gone_postal<%=id_suffix%>"><%= _('A response will be sent <strong>by post</strong>') %></label>
</div>

<%= render :partial => 'general/custom_state_transitions_pending', :locals => {:id_suffix => id_suffix } %>

<hr> <!------------------------------------------------>
<h3>This particular request is finished:</h3>

<% if @info_request.described_state == 'internal_review' %>
<p><%= _('The <strong>review has finished</strong> and overall:') %></p>
Expand All @@ -56,6 +59,8 @@
<%= radio_button "incoming_message", "described_state", "rejected", :id => 'rejected' + id_suffix %>
<label for="rejected<%=id_suffix%>"><%= _('The request has been <strong>refused</strong>') %></label>
</div>

<%= render :partial => 'general/custom_state_transitions_complete', :locals => {:id_suffix => id_suffix } %>

<hr> <!------------------------------------------------>

Expand Down
8 changes: 1 addition & 7 deletions app/views/request/show.rhtml
Expand Up @@ -86,12 +86,6 @@
<%= _('The request was <strong>refused</strong> by') %> <%= public_body_link(@info_request.public_body) %>.
<% elsif @status == 'successful' %>
<%= _('The request was <strong>successful</strong>.') %>
<% elsif @status == 'deadline_extended' %>
Currently <strong>deadline extended</strong> from <%= public_body_link(@info_request.public_body) %>,
they must respond promptly and normally no later than <strong><%= simple_date(@info_request.date_deadline_extended) %></strong>
(<%= link_to "details", "/help/requesting#deadline_extended" %>).
<% elsif @status == 'wrong_response' %>
<%= public_body_link(@info_request.public_body) %> has replied but the response <strong>does not correspond to the request</strong>.
<% elsif @status == 'partially_successful' %>
<%= _('The request was <strong>partially successful</strong>.') %>
<% elsif @status == 'waiting_clarification' %>
Expand All @@ -116,7 +110,7 @@
<%= _('This request has been <strong>withdrawn</strong> by the person who made it.
There may be an explanation in the correspondence below.') %>
<% else %>
<% raise "unknown status " + @status %>
<%= render :partial => 'general/custom_state_descriptions', :locals => { :status => @status } %>
<% end %>
</p>

Expand Down

0 comments on commit 35e4ffd

Please sign in to comment.