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

Inherits:
DefaultPermissions show all
Defined in:
decidim-budgets/app/permissions/decidim/budgets/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
# File 'decidim-budgets/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
      permission_action.allow!
    when :import_proposals
      permission_action.allow!
    when :update, :destroy
      permission_action.allow! if project.present?
    end
  end

  permission_action
end