diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-08-24 11:50:56 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-08-24 11:50:56 +0100 |
commit | a500ae3334dd1cbd8a46e2515857ad05a1a43e30 (patch) | |
tree | 8eb92537b9582aeffe7798336bbb92342ac33138 /app/models/info_request_event.rb | |
parent | 6675866787bf2c9cb095b8154fbdae33a1fb71c4 (diff) | |
parent | 87f7fbd076fc301262fc0a628d81b3a1bd3688e7 (diff) |
Merge branch 'develop' of github.com:sebbacon/alaveteli into feature/more-filter-and-search-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 d8ab0e446..fbf70332d 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" |