Sha256: a7f6fba53397e809baeb8f4f4cbaa3a04fd66ea2f04535571566bfc7816c2b36

Contents?: true

Size: 1.89 KB

Versions: 11

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    # A controller that holds the logic to show Assemblies in a
    # public layout.
    class AssembliesController < Decidim::Assemblies::ApplicationController
      include ParticipatorySpaceContext
      participatory_space_layout only: :show

      helper Decidim::AttachmentsHelper
      helper Decidim::IconHelper
      helper Decidim::WidgetUrlsHelper
      helper Decidim::SanitizeHelper
      helper Decidim::ResourceReferenceHelper

      helper_method :collection, :promoted_assemblies, :assemblies, :stats, :assembly_participatory_processes

      def index
        redirect_to "/404" if published_assemblies.none?

        enforce_permission_to :list, :assembly
      end

      def show
        check_current_user_can_visit_space
      end

      private

      def current_participatory_space
        return unless params[:slug]

        @current_participatory_space ||= OrganizationAssemblies.new(current_organization).query.where(slug: params[:slug]).or(
          OrganizationAssemblies.new(current_organization).query.where(id: params[:slug])
        ).first!
      end

      def published_assemblies
        @published_assemblies ||= OrganizationPublishedAssemblies.new(current_organization, current_user)
      end

      def assemblies
        @assemblies ||= OrganizationPrioritizedAssemblies.new(current_organization, current_user)
      end

      alias collection assemblies

      def promoted_assemblies
        @promoted_assemblies ||= assemblies | PromotedAssemblies.new
      end

      def stats
        @stats ||= AssemblyStatsPresenter.new(assembly: current_participatory_space)
      end

      def assembly_participatory_processes
        @assembly_participatory_processes ||= @current_participatory_space.linked_participatory_space_resources(:participatory_processes, "included_participatory_processes")
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-assemblies-0.14.4 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.14.3 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.14.2 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.14.1 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.13.1 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.12.2 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.13.0 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.12.1 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.13.0.pre1 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.12.0 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.12.0.pre app/controllers/decidim/assemblies/assemblies_controller.rb