Sha256: 354a9b1c3d612cdd1f72cba7df00572a0d7b84bec69340c6e8df25150e04785b

Contents?: true

Size: 1.31 KB

Versions: 31

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module ContentBlocks
      module LandingPage
        class ElectionsCell < Decidim::ViewModel
          delegate :current_participatory_space, to: :controller

          def show
            if single?
              render :single
            else
              render :show
            end
          end

          private

          def published_election_component_ids
            @published_election_component_ids ||= Decidim::Component
                                                  .where(
                                                    participatory_space: current_participatory_space,
                                                    manifest_name: :elections
                                                  )
                                                  .published
                                                  .pluck(:id)
          end

          def elections
            @elections ||= Decidim::Elections::Election
                           .where(component: published_election_component_ids)
                           .published
          end

          def elections_count
            @elections_count ||= elections.count
          end

          def single?
            elections.one?
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-elections-0.27.9 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.8 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.7 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.6 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.26.10 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.26.9 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.5 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.26.8 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.4 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.3 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.26.7 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.26.5 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.2 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.1 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.26.4 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.0 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.26.3 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.0.rc2 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.27.0.rc1 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb
decidim-elections-0.26.2 app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb