Sha256: c1c1ad7a8e798ddaca132ed5285d72e704669c7cb436588182412f021dd9a5c0
Contents?: true
Size: 1.22 KB
Versions: 19
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module Decidim module Votings class Permissions < Decidim::DefaultPermissions def permissions allowed_public_anonymous_action? return permission_action unless user return Decidim::Votings::Admin::Permissions.new(user, permission_action, context).permissions if admin_scope? # Delegate the polling_officer_zone permission checks to the polling officer zone permissions class return Decidim::Votings::PollingOfficerZone::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :polling_officer_zone permission_action end private def voting @voting ||= context.fetch(:voting, nil) end def allowed_public_anonymous_action? return unless permission_action.action == :read return unless permission_action.scope == :public case permission_action.subject when :votings, :participatory_space allow! when :voting toggle_allow(voting.published? || user&.admin?) end end def admin_scope? permission_action.scope == :admin || permission_action.subject == :admin_dashboard end end end end
Version data entries
19 entries across 19 versions & 1 rubygems