Class: Decidim::Meetings::Permissions

Inherits:
DefaultPermissions
  • Object
show all
Defined in:
app/permissions/decidim/meetings/permissions.rb

Instance Method Summary collapse

Instance Method Details

#permissionsObject



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

def permissions
  return permission_action unless user

  # Delegate the admin permission checks to the admin permissions class
  return Decidim::Meetings::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 != :meeting

  case permission_action.action
  when :join
    toggle_allow(can_join_meeting?)
  when :leave
    toggle_allow(can_leave_meeting?)
  when :decline_invitation
    toggle_allow(can_decline_invitation?)
  end

  permission_action
end