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

Inherits:
DefaultPermissions
  • Object
show all
Defined in:
app/permissions/decidim/sortitions/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
# File '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