Class: Decidim::Assemblies::Abilities::Admin::AssemblyAdminAbility

Inherits:
AssemblyRoleAbility show all
Defined in:
app/models/decidim/assemblies/abilities/admin/assembly_admin_ability.rb

Overview

Defines the abilities for an assembly admin user. Intended to be used with ‘cancancan`.

Instance Method Summary collapse

Methods inherited from AssemblyRoleAbility

#assemblies_with_role_privileges, #can_manage_assembly?, #current_assembly, #has_manageable_assemblies?, #initialize, #not_admin?

Constructor Details

This class inherits a constructor from Decidim::Assemblies::Abilities::Admin::AssemblyRoleAbility

Instance Method Details

#define_abilitiesObject



10
11
12
13
14
15
16
17
18
19
# File 'app/models/decidim/assemblies/abilities/admin/assembly_admin_ability.rb', line 10

def define_abilities
  super

  can :manage, Assembly do |assembly|
    can_manage_assembly?(assembly)
  end

  cannot :create, Assembly
  cannot :destroy, Assembly
end

#define_assembly_abilitiesObject



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
# File 'app/models/decidim/assemblies/abilities/admin/assembly_admin_ability.rb', line 25

def define_assembly_abilities
  can :manage, Feature do |feature|
    can_manage_assembly?(feature.participatory_space)
  end

  can :manage, Category do |category|
    can_manage_assembly?(category.participatory_space)
  end

  can :manage, Attachment do |attachment|
    attachment.attached_to.is_a?(Decidim::Assembly) && can_manage_assembly?(attachment.attached_to)
  end

  can :manage, AssemblyUserRole do |role|
    can_manage_assembly?(role.assembly) && role.user != @user
  end

  can :manage, Moderation do |moderation|
    can_manage_assembly?(moderation.participatory_space)
  end

  can [:unreport, :hide], Reportable do |reportable|
    can_manage_assembly?(reportable.feature.participatory_space)
  end
end

#roleObject



21
22
23
# File 'app/models/decidim/assemblies/abilities/admin/assembly_admin_ability.rb', line 21

def role
  :admin
end