aboutsummaryrefslogtreecommitdiffstats
path: root/lib/customstates.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/customstates.rb')
-rw-r--r--lib/customstates.rb90
1 files changed, 53 insertions, 37 deletions
diff --git a/lib/customstates.rb b/lib/customstates.rb
index c09eb8c..d801c92 100644
--- a/lib/customstates.rb
+++ b/lib/customstates.rb
@@ -1,50 +1,66 @@
-# See `doc/THEMES.md` for more explanation of this file
-# This example adds a "transferred" state to requests.
+# See `http://alaveteli.org/docs/customising/themes/#customising-the-request-states`
+# for more explanation of this file
module InfoRequestCustomStates
- def self.included(base)
- base.extend(ClassMethods)
- end
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ # Work out what the situation of the request is. In addition to
+ # values of self.described_state, in base Alaveteli can return
+ # these (calculated) values:
+ # waiting_classification
+ # waiting_response_overdue
+ # waiting_response_very_overdue
+ def theme_calculate_status
+ # just fall back to the core calculation
+ return self.base_calculate_status
+ end
+
+ # Mixin methods for InfoRequest
+ module ClassMethods
- # Work out what the situation of the request is. In addition to
- # values of self.described_state, in base Alaveteli can return
- # these (calculated) values:
- # waiting_classification
- # waiting_response_overdue
- # waiting_response_very_overdue
- def theme_calculate_status
- # just fall back to the core calculation
- return self.base_calculate_status
+ # Return the name of a custom status.
+ # Example of how to add a custom status:
+ # def theme_display_status(status)
+ # if status == 'transferred'
+ # _("Transferred.")
+ # else
+ # raise _("unknown status ") + status
+ # end
+ # end
+ def theme_display_status(status)
+ raise _("unknown status ") + status
end
- # Mixin methods for InfoRequest
- module ClassMethods
- def theme_display_status(status)
- if status == 'transferred'
- _("Transferred.")
- else
- raise _("unknown status ") + status
- end
- end
-
- def theme_extra_states
- return ['transferred']
- end
+ # Return the list of custom statuses added by the theme.
+ # Example of how to add a custom status:
+ # def theme_extra_states
+ # return ['transferred']
+ # end
+ def theme_extra_states
+ return []
end
+
+ 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 == 'transferred'
- flash[:notice] = _("Authority has transferred your request to a different public body.")
- redirect_to request_url(@info_request)
- else
- raise "unknown calculate_status " + info_request.calculate_status
- end
- end
+ # `theme_describe_state` is called after the core describe_state code.
+ # It should end by raising an error if the status is unknown.
+ # Example of how to add a custom status:
+ # def theme_describe_state(info_request)
+ # if info_request.calculate_status == 'transferred'
+ # flash[:notice] = _("Authority has transferred your request to a different public body.")
+ # redirect_to request_url(@info_request)
+ # else
+ # raise "unknown calculate_status " + info_request.calculate_status
+ # end
+ # end
+ def theme_describe_state(info_request)
+ raise "unknown calculate_status " + info_request.calculate_status
+ end
end