Sha256: badd5962cd55b05205170b9f3e3b215c664cd50b6ead16628bc731e0230be8b8

Contents?: true

Size: 1.69 KB

Versions: 7

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

module Decidim
  module Consultations
    # A controller that holds the logic to show consultations in a
    # public layout.
    class ConsultationsController < Decidim::Consultations::ApplicationController
      layout "layouts/decidim/consultation", only: :show

      include NeedsConsultation
      include FilterResource
      include Paginable
      include Orderable
      include ParticipatorySpaceContext

      helper_method :collection, :consultations, :finished_consultations, :active_consultations, :filter

      helper Decidim::FiltersHelper
      helper Decidim::OrdersHelper
      helper Decidim::SanitizeHelper
      helper Decidim::PaginateHelper
      helper Decidim::IconHelper
      helper Decidim::WidgetUrlsHelper
      helper Decidim::ResourceHelper

      def index
        enforce_permission_to :read, :consultation_list
      end

      def show
        enforce_permission_to :read, :consultation, consultation: current_consultation
      end

      private

      def current_participatory_space_manifest
        @current_participatory_space_manifest ||= Decidim.find_participatory_space_manifest(:consultations)
      end

      def consultations
        @consultations = search.results
        @consultations = reorder(@consultations)
        @consultations = paginate(@consultations)
      end

      alias collection consultations

      def search_klass
        ConsultationSearch
      end

      def default_filter_params
        {
          search_text: "",
          state: "all"
        }
      end

      def context_params
        {
          organization: current_organization,
          current_user: current_user
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-consultations-0.18.1 app/controllers/decidim/consultations/consultations_controller.rb
decidim-consultations-0.17.2 app/controllers/decidim/consultations/consultations_controller.rb
decidim-consultations-0.18.0 app/controllers/decidim/consultations/consultations_controller.rb
decidim-consultations-0.17.1 app/controllers/decidim/consultations/consultations_controller.rb
decidim-consultations-0.16.1 app/controllers/decidim/consultations/consultations_controller.rb
decidim-consultations-0.17.0 app/controllers/decidim/consultations/consultations_controller.rb
decidim-consultations-0.16.0 app/controllers/decidim/consultations/consultations_controller.rb