Class: Decidim::Admin::Permissions

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

Instance Method Summary collapse

Methods inherited from 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'decidim-admin/app/permissions/decidim/admin/permissions.rb', line 6

def permissions
  return permission_action if managed_user_action?

  unless permission_action.scope == :admin
    read_admin_dashboard_action?
    return permission_action
  end

  unless user
    disallow!
    return permission_action
  end

  if user_manager?
    begin
      allow! if user_manager_permissions.allowed?
    rescue Decidim::PermissionAction::PermissionNotSetError
      nil
    end
  end

  allow! if user_can_enter_space_area?(require_admin_terms_accepted: true)

  read_admin_dashboard_action?
  apply_newsletter_permissions_for_admin!

  allow! if permission_action.subject == :global_moderation

  if user.admin? && admin_terms_accepted?
    allow! if read_admin_log_action?
    allow! if read_metrics_action?
    allow! if static_page_action?
    allow! if organization_action?
    allow! if user_action?

    allow! if permission_action.subject == :category
    allow! if permission_action.subject == :component
    allow! if permission_action.subject == :admin_user
    allow! if permission_action.subject == :attachment
    allow! if permission_action.subject == :attachment_collection
    allow! if permission_action.subject == :scope
    allow! if permission_action.subject == :scope_type
    allow! if permission_action.subject == :area
    allow! if permission_action.subject == :area_type
    allow! if permission_action.subject == :user_group
    allow! if permission_action.subject == :officialization
    allow! if permission_action.subject == :moderate_users
    allow! if permission_action.subject == :authorization
    allow! if permission_action.subject == :authorization_workflow
    allow! if permission_action.subject == :static_page_topic
    allow! if permission_action.subject == :help_sections
    allow! if permission_action.subject == :share_token
  end

  permission_action
end