Sha256: 6517e8673c8f3280b9d7b6e4409cb9a1da9cf181e6b322319503a0ac117cf22c

Contents?: true

Size: 1.86 KB

Versions: 18

Compression:

Stored size: 1.86 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    # A controller that holds the logic to show ParticipatoryProcesses in a
    # public layout.
    class ParticipatoryProcessesController < Decidim::ApplicationController
      layout "layouts/decidim/participatory_process", only: [:show]

      before_action -> { extend NeedsParticipatoryProcess }, only: [:show]

      helper Decidim::AttachmentsHelper
      helper Decidim::IconHelper
      helper Decidim::WidgetUrlsHelper

      helper ParticipatoryProcessHelper

      helper_method :collection, :promoted_participatory_processes, :participatory_processes, :stats, :filter

      def index
        authorize! :read, ParticipatoryProcess
        authorize! :read, ParticipatoryProcessGroup
      end

      def show
        authorize! :read, current_participatory_process
      end

      private

      def collection
        @collection ||= (participatory_processes.to_a + participatory_process_groups).flatten
      end

      def filtered_participatory_processes(filter = default_filter)
        OrganizationPrioritizedParticipatoryProcesses.new(current_organization, filter)
      end

      def participatory_processes
        @participatory_processes ||= filtered_participatory_processes(filter)
      end

      def promoted_participatory_processes
        @promoted_processes ||= filtered_participatory_processes | PromotedParticipatoryProcesses.new
      end

      def participatory_process_groups
        @process_groups ||= OrganizationPrioritizedParticipatoryProcessGroups.new(current_organization, filter)
      end

      def stats
        @stats ||= ParticipatoryProcessStatsPresenter.new(participatory_process: current_participatory_process)
      end

      def filter
        @filter = params[:filter] || default_filter
      end

      def default_filter
        "active"
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
decidim-participatory_processes-0.6.8 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.8 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-participatory_processes-0.6.7 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.7 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-participatory_processes-0.6.6 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.6 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-participatory_processes-0.6.5 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.5 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-participatory_processes-0.6.4 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.4 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-participatory_processes-0.6.3 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.3 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-participatory_processes-0.6.2 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.2 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-participatory_processes-0.6.1 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.1 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-participatory_processes-0.6.0 app/controllers/decidim/participatory_processes/participatory_processes_controller.rb
decidim-0.6.0 decidim-participatory_processes/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb