Sha256: a0ef433dff6d72a1da8fedc59317a237e925236a1be8fa3a5452db30cdd94727

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    module Components
      # This controller is the abstract class from which all component
      # controllers in their admin engines should inherit from.
      class BaseController < Admin::ApplicationController
        skip_authorize_resource
        include Settings

        include Decidim::Admin::ParticipatorySpaceAdminContext
        participatory_space_admin_layout

        helper Decidim::ResourceHelper
        helper Decidim::Admin::ExportsHelper
        helper Decidim::Admin::BulkActionsHelper

        helper_method :current_component,
                      :current_participatory_space,
                      :parent_path

        before_action except: [:index, :show] do
          authorize! :manage, current_component
        end

        before_action on: [:index, :show] do
          authorize! :read, current_component
        end

        def current_component
          request.env["decidim.current_component"]
        end

        def current_participatory_space
          current_component.participatory_space
        end

        def parent_path
          @parent_path ||= EngineRouter.admin_proxy(current_participatory_space).components_path
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-admin-0.11.2 app/controllers/decidim/admin/components/base_controller.rb
decidim-admin-0.11.1 app/controllers/decidim/admin/components/base_controller.rb
decidim-admin-0.11.0.pre1 app/controllers/decidim/admin/components/base_controller.rb