Class: Decidim::Initiatives::Admin::Permissions

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


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
# File 'decidim-initiatives/app/permissions/decidim/initiatives/admin/permissions.rb', line 7

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

  user_can_enter_space_area?

  return permission_action if initiative && !initiative.is_a?(Decidim::Initiative)

  user_can_read_participatory_space?

  if !user.admin? && initiative&.has_authorship?(user)
    initiative_committee_action?
    initiative_user_action?
    attachment_action?
    initiatives_settings_action?

    return permission_action
  end

  if !user.admin? && has_initiatives?
    read_initiative_list_action?

    return permission_action
  end

  return permission_action unless user.admin?

  initiative_type_action?
  initiative_type_scope_action?
  initiative_committee_action?
  initiative_admin_user_action?
  initiative_export_action?
  initiatives_settings_action?
  moderator_action?
  allow! if permission_action.subject == :attachment

  permission_action
end