Sha256: b2df854b6c953608ff8eb467349c702227a7cd514381422bc934ce74fd5b46ca

Contents?: true

Size: 563 Bytes

Versions: 13

Compression:

Stored size: 563 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module <%= component_module_name %>
    module Admin
      class Permissions < Decidim::DefaultPermissions
        def permissions
          return permission_action if permission_action.scope != :admin
          return permission_action unless user&.admin?

          allow! if can_access?

          permission_action
        end

        def can_access?
          permission_action.subject == :<%= component_name.to_sym %> &&
            permission_action.action == :read
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-generators-0.29.1 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.28.4 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.29.0 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.28.3 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.29.0.rc4 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.29.0.rc3 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.29.0.rc2 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.29.0.rc1 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.28.2 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.28.1 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.28.0 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.28.0.rc5 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb
decidim-generators-0.28.0.rc4 lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb