diff options
author | David Cabo <david@calibea.com> | 2011-08-23 23:11:54 +0200 |
---|---|---|
committer | David Cabo <david@calibea.com> | 2011-08-23 23:11:54 +0200 |
commit | c051e602934a8922a4749f21d11b860db0a8b1dc (patch) | |
tree | 2a4897e584e01467966fa41aa69ad034b7228959 | |
parent | 3078850c9e45ff0c8531cf80f1f67642ddd8c5ac (diff) |
Replace hardcoded state list in InfoRequestState with customizable one from InfoRequest (fixes #155)
-rw-r--r-- | app/models/info_request_event.rb | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index d79647c98..1550a4bf5 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -57,22 +57,7 @@ class InfoRequestEvent < ActiveRecord::Base ] # user described state (also update in info_request) - validates_inclusion_of :described_state, :in => [ - nil, - 'waiting_response', - 'waiting_clarification', - 'gone_postal', - 'deadline_extended', - 'wrong_response', - 'not_held', - 'rejected', - 'successful', - 'partially_successful', - 'internal_review', - 'error_message', - 'requires_admin', - 'user_withdrawn' - ] + validate :must_be_valid_state # whether event is publicly visible validates_inclusion_of :prominence, :in => [ @@ -81,6 +66,12 @@ class InfoRequestEvent < ActiveRecord::Base 'requester_only' ] + def must_be_valid_state + if !described_state.nil? and !InfoRequest.enumerate_states.include?(described_state) + errors.add(described_state, "is not a valid state") + end + end + def user_can_view?(user) if !self.info_request.user_can_view?(user) raise "internal error, called user_can_view? on event when there is not permission to view entire request" |