Sha256: ef36489b56157ec796ce068fbf82c240e4b3bbce7b0b3c446ea987cb1c1a7f6d
Contents?: true
Size: 1.24 KB
Versions: 6
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module Decidim module Comments class Permissions < Decidim::DefaultPermissions def permissions return permission_action if permission_action.subject != :comment case permission_action.action when :read can_read_comments? when :create can_create_comment? when :vote can_vote_comment? end permission_action end private def can_read_comments? return disallow! unless commentable.commentable? allow! end def can_create_comment? return disallow! unless user return disallow! unless commentable.commentable? return disallow! unless commentable&.user_allowed_to_comment?(user) allow! end def can_vote_comment? return disallow! unless user return disallow! unless commentable&.user_allowed_to_comment?(user) allow! end def commentable @commentable ||= begin if comment comment.root_commentable else context.fetch(:commentable, nil) end end end def comment @comment ||= context.fetch(:comment, nil) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems