Class: Decidim::Budgets::Admin::Permissions

Inherits:
DefaultPermissions
  • Object
show all
Defined in:
app/permissions/decidim/budgets/admin/permissions.rb

Instance Method Summary collapse

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

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

  case permission_action.subject
  when :budget
    case permission_action.action
    when :create, :read, :export
      allow!
    when :update
      toggle_allow(budget)
    when :delete, :publish, :unpublish
      toggle_allow(budget && budget.projects.empty?)
    end
  when :project, :projects
    case permission_action.action
    when :create, :import_proposals, :project_category
      permission_action.allow!
    when :update, :destroy
      permission_action.allow! if project.present?
    end
  when :order
    case permission_action.action
    when :remind
      permission_action.allow!
    end
  when :project_category, :project_scope, :project_selected
    permission_action.allow!
  end

  permission_action
end