Class: Decidim::Debates::Permissions

Inherits:
Decidim::DefaultPermissions show all
Defined in:
decidim-debates/app/permissions/decidim/debates/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


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'decidim-debates/app/permissions/decidim/debates/permissions.rb', line 6

def permissions
  # Delegate the admin permission checks to the admin permissions class
  return Decidim::Debates::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin
  return permission_action if permission_action.scope != :public

  return permission_action if permission_action.subject != :debate

  case permission_action.action
  when :create
    toggle_allow(can_create_debate?)
  when :report
    allow!
  when :edit
    can_edit_debate?
  when :endorse
    can_endorse_debate?
  when :close
    can_close_debate?
  end

  permission_action
end