Class: Decidim::Proposals::Abilities::ProcessAdminUser
- Inherits:
-
Object
- Object
- Decidim::Proposals::Abilities::ProcessAdminUser
- Includes:
- CanCan::Ability
- Defined in:
- decidim-proposals/app/models/decidim/proposals/abilities/process_admin_user.rb
Overview
Defines the abilities related to proposals for a logged in process admin user. Intended to be used with ‘cancancan`.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user, context) ⇒ ProcessAdminUser
constructor
A new instance of ProcessAdminUser.
Constructor Details
#initialize(user, context) ⇒ ProcessAdminUser
Returns a new instance of ProcessAdminUser.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'decidim-proposals/app/models/decidim/proposals/abilities/process_admin_user.rb', line 13 def initialize(user, context) return unless user && !user.role?(:admin) @user = user @context = context can :manage, Proposal do |proposal| participatory_processes.include?(proposal.feature.participatory_process) end can :unreport, Proposal can :hide, Proposal cannot :create, Proposal unless can_create_proposal? cannot :update, Proposal unless can_update_proposal? end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
11 12 13 |
# File 'decidim-proposals/app/models/decidim/proposals/abilities/process_admin_user.rb', line 11 def context @context end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
11 12 13 |
# File 'decidim-proposals/app/models/decidim/proposals/abilities/process_admin_user.rb', line 11 def user @user end |