Sha256: f77ab0763d8cd1388eb99849eeead70a2beca4dc7e2e458d5635c70bedba258e

Contents?: true

Size: 1.91 KB

Versions: 72

Compression:

Stored size: 1.91 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # This module contains all the logic needed for a controller to render a participatory space
    # public layout. modqule ParticipatorySpaceAdminContext
    module ParticipatorySpaceAdminContext
      extend ActiveSupport::Concern

      class_methods do
        # Public: Called on a controller, it sets up all the surrounding methods to render a
        # participatory space's admin template. It expects the method `current_participatory_space`
        # to be defined, from which it will extract the participatory manifest.
        #
        # options - A hash used to modify the behavior of the layout. :only: - An array of actions
        #         on which the layout will be applied.
        #
        # Returns nothing.
        def participatory_space_admin_layout(options = {})
          layout :layout, options
          before_action :authorize_participatory_space, options
        end
      end

      included do
        include Decidim::NeedsOrganization
        helper ParticipatorySpaceHelpers

        helper_method :current_participatory_space
        helper_method :current_participatory_space_manifest
        helper_method :current_participatory_space_context

        delegate :manifest, to: :current_participatory_space, prefix: true
      end

      private

      def current_participatory_space_context
        :admin
      end

      def current_participatory_space
        raise NotImplementedError
      end

      def authorize_participatory_space
        enforce_permission_to :read, :participatory_space, current_participatory_space: current_participatory_space
      end

      def permissions_context
        super.merge(
          current_participatory_space: current_participatory_space
        )
      end

      def layout
        current_participatory_space_manifest.context(current_participatory_space_context).layout
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
decidim-admin-0.27.9 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.8 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.7 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.6 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.26.10 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.26.9 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.5 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.26.8 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.4 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.3 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.26.7 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.26.5 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.2 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.1 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.26.4 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.0 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.26.3 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.0.rc2 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.27.0.rc1 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb
decidim-admin-0.26.2 app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb