diff options
Diffstat (limited to 'app/models/info_request_event.rb')
-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" |