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

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

  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 :delete, :close
    toggle_allow(debate && debate.official?)
  end

  permission_action
end