Sha256: c9f54a89dbf427e8a88b0a31527df1cbcb59867e88f302cc2bd03cde0e9ff558

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 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 FeatureSettings
      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::OrganizationScopesHelper
      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_participatory_process: current_participatory_process,
          current_settings: current_settings,
          feature_settings: feature_settings
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.4.2 app/controllers/decidim/features/base_controller.rb
decidim-core-0.4.1 app/controllers/decidim/features/base_controller.rb
decidim-core-0.4.3 app/controllers/decidim/features/base_controller.rb
decidim-core-0.4.0 app/controllers/decidim/features/base_controller.rb