Sha256: 6153785b59580303228bdc93696c83e1b60ed0b2d7bbb26c586059fc0d4141b0

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 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::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_settings: current_settings,
          feature_settings: feature_settings
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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