Class: Decidim::Sortitions::Admin::Permissions

Inherits:
DefaultPermissions show all
Defined in:
decidim-sortitions/app/permissions/decidim/sortitions/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
# File 'decidim-sortitions/app/permissions/decidim/sortitions/admin/permissions.rb', line 7

def permissions
  return permission_action unless user

  return permission_action if permission_action.scope != :admin

  return permission_action if permission_action.subject != :sortition

  case permission_action.action
  when :destroy
    permission_action.allow! if sortition.present? && !sortition.cancelled?
  when :update
    permission_action.allow! if sortition.present?
  when :create, :read
    permission_action.allow!
  end

  permission_action
end