Sha256: 28281bc0bd55065e7ed4f5c980731ae134ea75d49dbe2cca65b67ebc6d4c1b05

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

module Decidim
  module Features
    # Controller from which all feature engines inherit from. It's in charge of
    # setting the appropiate layout, including necessary helpers, and overall
    # fooling the engine into thinking it's isolated.
    class BaseController < Decidim::ApplicationController
      layout "layouts/decidim/participatory_process"
      include NeedsParticipatoryProcess
      include Settings
      include ActionAuthorization

      helper Decidim::FiltersHelper
      helper Decidim::OrdersHelper
      helper Decidim::FeatureReferenceHelper
      helper Decidim::TranslationsHelper
      helper Decidim::ParticipatoryProcessHelper
      helper Decidim::IconHelper
      helper Decidim::ResourceHelper
      helper Decidim::ScopesHelper
      helper Decidim::ActionAuthorizationHelper
      helper Decidim::AttachmentsHelper

      helper_method :current_feature,
                    :current_manifest

      skip_authorize_resource

      before_action do
        authorize! :read, current_participatory_process
        authorize! :read, current_feature
      end

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

      def current_manifest
        @current_manifest ||= current_feature.manifest
      end

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

      def ability_context
        super.merge(
          current_manifest: current_manifest,
          current_settings: current_settings,
          feature_settings: feature_settings
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
decidim-core-0.5.1 app/controllers/decidim/features/base_controller.rb
decidim-0.5.1 decidim-core/app/controllers/decidim/features/base_controller.rb
decidim-core-0.5.0 app/controllers/decidim/features/base_controller.rb
decidim-0.5.0 decidim-core/app/controllers/decidim/features/base_controller.rb