blob: b9c2226a43aa0fe281679a9fb17e18178f26ce00 (
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
|
class VotingOption < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
description :string
timestamps
end
belongs_to :agenda_item, :null => false
has_many :votes
validates_presence_of :agenda_item
validates_uniqueness_of :description, :scope => :agenda_item_id
def name
description
end
# --- Permissions --- #
def create_permitted?
acting_user.council_member?
end
def update_permitted?
return false unless acting_user.council_member?
return true if agenda_item.nil?
return true if agenda_item.agenda.nil?
return true if agenda_item.agenda.state == 'open'
false
end
def destroy_permitted?
updatable_by?(acting_user)
end
def view_permitted?(field)
true
end
end
|