Permalink
Browse files

files required for custom request states

  • Loading branch information...
sebbacon committed Jul 12, 2011
1 parent ac397a3 commit 2b240491237bd72415990399904361ce9bfa431d
View
@@ -1,3 +1,5 @@
require 'customstates'
class ActionController::Base
before_filter :set_view_paths
View
@@ -0,0 +1,62 @@
module InfoRequestCustomStates
# Mixin methods for InfoRequest
def theme_display_status(status)
if status == 'deadline_extended'
_("Deadline extended.")
elsif status == 'wrong_response'
_("Wrongs Response.")
else
raise _("unknown status ") + status
end
end
def theme_extra_states
return ['deadline_extended',
'wrong_response']
end
def theme_calculate_status
return 'waiting_classification' if self.awaiting_description
waiting_response = self.described_state == "waiting_response" || self.described_state == "deadline_extended"
return self.described_state unless waiting_response
if self.described_state == 'deadline_extended'
return 'deadline_extended' if
Time.now.strftime("%Y-%m-%d") < self.date_deadline_extended.strftime("%Y-%m-%d")
return 'waiting_response_very_overdue' if
Time.now.strftime("%Y-%m-%d") > Holiday.due_date_from(self.date_deadline_extended, 15).strftime("%Y-%m-%d")
return 'waiting_response_overdue'
end
return 'waiting_response_very_overdue' if
Time.now.strftime("%Y-%m-%d") > self.date_very_overdue_after.strftime("%Y-%m-%d")
return 'waiting_response_overdue' if
Time.now.strftime("%Y-%m-%d") > self.date_response_required_by.strftime("%Y-%m-%d")
return 'waiting_response'
end
def date_deadline_extended
# XXX shouldn't this be 15 days after the date the status was
# changed to "deadline extended"? Or perhaps 15 days ater the
# initial request due date?
return Holiday.due_date_from(self.date_response_required_by, 15)
end
end
module RequestControllerCustomStates
def theme_describe_state(info_request)
# called after the core describe_state code. It should
# end by raising an error if the status is unknown
if 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)
else
raise "unknown calculate_status " + info_request.calculate_status
end
end
end
@@ -0,0 +1,9 @@
<% if 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>.
<% else %>
<% raise "unknown status " + status %>
<% end %>
@@ -0,0 +1,4 @@
<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>
@@ -0,0 +1,5 @@
<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>
@@ -0,0 +1,4 @@
<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>

0 comments on commit 2b24049

Please sign in to comment.