aboutsummaryrefslogtreecommitdiffstats
path: root/lib/customstates.rb
blob: 323a1058a935bb6cf63a29ce05e8f37e49ba2e6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- encoding : utf-8 -*-
# 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

  # 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

    # 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

    # 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

  # `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