Sha256: ac0ef0a0cefe4e934fa91aebc673544ef288c74ad3c231ed539b10939b3e742f
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Decidim module Proposals module Abilities # Defines the abilities related to proposals for a logged in admin user. # Intended to be used with `cancancan`. class AdminAbility < Decidim::Abilities::AdminAbility def define_abilities super can :manage, Proposal can :unreport, Proposal can :hide, Proposal cannot :create, Proposal unless can_create_proposal? cannot :update, Proposal unless can_update_proposal? can :create, ProposalNote end private def current_settings @context.fetch(:current_settings, nil) end def component_settings @context.fetch(:component_settings, nil) end def can_create_proposal? current_settings.try(:creation_enabled?) && component_settings.try(:official_proposals_enabled) end def can_update_proposal? current_settings.try(:proposal_answering_enabled) && component_settings.try(:proposal_answering_enabled) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems