diff options
-rw-r--r-- | app/controllers/request_controller.rb | 14 | ||||
-rw-r--r-- | app/models/info_request.rb | 20 | ||||
-rw-r--r-- | app/views/general/_custom_state_descriptions.rhtml | 1 | ||||
-rw-r--r-- | app/views/general/_custom_state_transitions_complete.rhtml | 0 | ||||
-rw-r--r-- | app/views/general/_custom_state_transitions_pending.rhtml | 0 | ||||
-rw-r--r-- | app/views/request/_describe_state.rhtml | 16 | ||||
-rw-r--r-- | app/views/request/_other_describe_state.rhtml | 7 | ||||
-rw-r--r-- | app/views/request/show.rhtml | 8 |
8 files changed, 35 insertions, 31 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index b17717002..103349311 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -52,6 +52,7 @@ class RequestController < ApplicationController ) 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 @@ -368,7 +369,6 @@ class RequestController < ApplicationController 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> @@ -407,12 +407,6 @@ class RequestController < ApplicationController 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) @@ -426,7 +420,11 @@ class RequestController < ApplicationController 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 diff --git a/app/models/info_request.rb b/app/models/info_request.rb index b9c39e89d..07245bdfd 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -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', @@ -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', @@ -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) diff --git a/app/views/general/_custom_state_descriptions.rhtml b/app/views/general/_custom_state_descriptions.rhtml new file mode 100644 index 000000000..913a6d50a --- /dev/null +++ b/app/views/general/_custom_state_descriptions.rhtml @@ -0,0 +1 @@ + <% raise "unknown status " + status %> diff --git a/app/views/general/_custom_state_transitions_complete.rhtml b/app/views/general/_custom_state_transitions_complete.rhtml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/app/views/general/_custom_state_transitions_complete.rhtml diff --git a/app/views/general/_custom_state_transitions_pending.rhtml b/app/views/general/_custom_state_transitions_pending.rhtml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/app/views/general/_custom_state_transitions_pending.rhtml diff --git a/app/views/request/_describe_state.rhtml b/app/views/request/_describe_state.rhtml index f1db6ec18..8164637bf 100644 --- a/app/views/request/_describe_state.rhtml +++ b/app/views/request/_describe_state.rhtml @@ -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 %> @@ -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> @@ -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 %> diff --git a/app/views/request/_other_describe_state.rhtml b/app/views/request/_other_describe_state.rhtml index 7bd4bf7ea..1c88f97f8 100644 --- a/app/views/request/_other_describe_state.rhtml +++ b/app/views/request/_other_describe_state.rhtml @@ -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 %> @@ -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> @@ -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> <!------------------------------------------------> diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml index af1d1b6d2..c8f5f3eed 100644 --- a/app/views/request/show.rhtml +++ b/app/views/request/show.rhtml @@ -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' %> @@ -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> |