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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'app/permissions/decidim/proposals/admin/permissions.rb', line 7
def permissions
return permission_action if permission_action.scope != :admin
if user_is_valuator?
if valuator_assigned_to_proposal?
can_create_proposal_note?
can_create_proposal_answer?
can_assign_valuator_to_proposal?
end
can_export_proposals?
return permission_action
end
if create_permission_action?
can_create_proposal_note?
can_create_proposal_from_admin?
can_create_proposal_answer?
end
allow! if permission_action.subject == :proposal && permission_action.action == :edit && admin_edition_is_available?
allow! if permission_action.subject == :proposal_category && permission_action.action == :update
allow! if permission_action.subject == :proposal_scope && permission_action.action == :update
allow! if permission_action.subject == :proposals && permission_action.action == :import
can_export_proposals?
allow! if permission_action.subject == :proposals && permission_action.action == :merge
allow! if permission_action.subject == :proposals && permission_action.action == :split
can_assign_valuator_to_proposal?
can_unassign_valuator_from_proposals?
toggle_allow(user.admin?) if permission_action.subject == :proposals && permission_action.action == :publish_answers
if permission_action.subject == :participatory_texts && participatory_texts_are_enabled? && permission_action.action == :manage
allow!
end
if permission_action.subject == :proposal_state
if permission_action.action == :destroy
toggle_allow(proposal_state.proposals.empty?)
else
allow!
end
end
permission_action
end
|