Sha256: 56ff9492860785466a8367980026c723e5ccf5cd99e1b0674004b4685cb21fe7

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 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::ApplicationController
      layout "layouts/decidim/assembly", only: [:show]

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

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

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

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

        authorize! :read, Assembly
      end

      def show
        authorize! :read, current_assembly
      end

      private

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

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

      alias collection assemblies

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-assemblies-0.8.3 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.8.2 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.8.1 app/controllers/decidim/assemblies/assemblies_controller.rb
decidim-assemblies-0.8.0 app/controllers/decidim/assemblies/assemblies_controller.rb