aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request_event.rb
diff options
context:
space:
mode:
authorRobin Houston <robin@lenny.robin>2011-08-25 17:27:59 +0100
committerRobin Houston <robin@lenny.robin>2011-08-25 17:27:59 +0100
commit50cd41b88b4421824e436d9189f8780b84c46a1a (patch)
tree8a2a33222e1f00f88ce102597db7de09fda5b6a0 /app/models/info_request_event.rb
parentbf949a62d7882c9d337e095bebd1e4ba6c4c6767 (diff)
parent87f7fbd076fc301262fc0a628d81b3a1bd3688e7 (diff)
Merge branch 'develop' of git@github.com:sebbacon/alaveteli into develop
Diffstat (limited to 'app/models/info_request_event.rb')
-rw-r--r--app/models/info_request_event.rb23
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"