Sha256: a5bd5dfdf996579fe2f7e99b50db3d425abfb60c0630fcb43353c29c4d36d74b
Contents?: true
Size: 875 Bytes
Versions: 8
Compression:
Stored size: 875 Bytes
Contents
# frozen_string_literal: true module Decidim module Comments module Abilities # Defines the abilities related to comments for a logged in process admin user. # Intended to be used with `cancancan`. class ProcessAdminUser include CanCan::Ability attr_reader :user, :context def initialize(user, context) return unless user && !user.role?(:admin) @user = user @context = context can :manage, Comment do |comment| participatory_processes.include?(comment.feature.participatory_process) end can :unreport, Comment can :hide, Comment end private def participatory_processes @participatory_processes ||= Decidim::Admin::ManageableParticipatoryProcessesForUser.for(@user) end end end end end
Version data entries
8 entries across 8 versions & 2 rubygems