Class: Decidim::Elections::Admin::Permissions

Inherits:
DefaultPermissions show all
Defined in:
decidim-elections/app/permissions/decidim/elections/admin/permissions.rb

Instance Method Summary collapse

Methods inherited from DefaultPermissions

#initialize

Constructor Details

This class inherits a constructor from Decidim::DefaultPermissions

Instance Method Details

#permissionsObject


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
# File 'decidim-elections/app/permissions/decidim/elections/admin/permissions.rb', line 7

def permissions
  return permission_action if permission_action.scope != :admin

  case permission_action.subject
  when :question, :answer
    case permission_action.action
    when :create, :update, :delete, :import_proposals
      allow_if_not_blocked
    when :select
      allow_if_results
    end
  when :steps
    case permission_action.action
    when :read, :update
      allow!
    end
  when :election
    case permission_action.action
    when :create, :read
      allow!
    when :delete, :update, :unpublish
      allow_if_not_blocked
    when :publish
      allow_if_valid_and_not_blocked
    end
  when :trustees
    case permission_action.action
    when :manage
      toggle_allow(user.admin?)
    end
  when :trustee_participatory_space
    case permission_action.action
    when :create, :update
      allow!
    when :delete
      allow_if_not_related_to_any_election
    end
  when :questionnaire
    case permission_action.action
    when :export_answers
      permission_action.allow!
    when :update
      toggle_allow(feedback_form.present?)
    end
  when :questionnaire_answers
    case permission_action.action
    when :index, :show, :export_response
      permission_action.allow!
    end
  end

  permission_action
end