Sha256: e10e49991f6ac95f00cd9146d8ca73b24eb081cba6bb7c173ab3250889f209a5

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module ContentBlocks
      class HighlightedAssembliesCell < Decidim::ViewModel
        delegate :current_user, to: :controller

        def show
          render if highlighted_assemblies.any?
        end

        def max_results
          model.settings.max_results
        end

        def highlighted_assemblies
          @highlighted_assemblies ||= OrganizationPrioritizedAssemblies
                                      .new(current_organization, current_user)
                                      .query
                                      .with_attached_hero_image
                                      .includes([:organization])
                                      .limit(max_results)
        end

        def i18n_scope
          "decidim.assemblies.pages.home.highlighted_assemblies"
        end

        def decidim_assemblies
          Decidim::Assemblies::Engine.routes.url_helpers
        end

        private

        def cache_hash
          hash = []
          hash.push(I18n.locale)
          hash.push(highlighted_assemblies.map(&:cache_key_with_version))
          hash.join(Decidim.cache_key_separator)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-assemblies-0.27.9 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.8 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.7 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.6 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.5 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.4 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.3 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.2 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.1 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.0 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb
decidim-assemblies-0.27.0.rc2 app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb