Sha256: 03dbec13a2fb7fa15ca29ad899c635eb8f7661a3ceca0f97faf94dddaa6fe3c1

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    module Features
      # This controller is the abstract class from which all feature
      # 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_method :current_feature,
                      :current_participatory_space,
                      :parent_path

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

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

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

        def current_participatory_space
          current_feature.participatory_space
        end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-admin-0.9.3 app/controllers/decidim/admin/features/base_controller.rb
decidim-admin-0.9.2 app/controllers/decidim/admin/features/base_controller.rb
decidim-admin-0.9.1 app/controllers/decidim/admin/features/base_controller.rb
decidim-admin-0.9.0 app/controllers/decidim/admin/features/base_controller.rb