Class: Decidim::Debates::Admin::Permissions

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

Instance Method Summary collapse

Methods inherited from Decidim::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
# File 'decidim-debates/app/permissions/decidim/debates/admin/permissions.rb', line 7

def permissions
  # The public part needs to be implemented yet
  return permission_action if permission_action.scope != :admin

  can_export_debates?

  return permission_action if permission_action.subject != :debate

  case permission_action.action
  when :create, :read, :export
    allow!
  when :update
    toggle_allow(debate && !debate.closed? && debate.official?)
  when :close
    toggle_allow(debate&.official?)
  end

  permission_action
end