Sha256: 582f66583e2f3d206f2405b4eaf7d7ac65be69aa6cf88ff5429711004eb93c73

Contents?: true

Size: 1.65 KB

Versions: 8

Compression:

Stored size: 1.65 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::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

8 entries across 8 versions & 1 rubygems

Version Path
decidim-core-0.3.2 app/controllers/decidim/features/base_controller.rb
decidim-core-0.3.1 app/controllers/decidim/features/base_controller.rb
decidim-core-0.3.0 app/controllers/decidim/features/base_controller.rb
decidim-core-0.2.0 app/controllers/decidim/features/base_controller.rb
decidim-core-0.1.0 app/controllers/decidim/features/base_controller.rb
decidim-core-0.0.8.1 app/controllers/decidim/features/base_controller.rb
decidim-core-0.0.7 app/controllers/decidim/features/base_controller.rb
decidim-core-0.0.6 app/controllers/decidim/features/base_controller.rb