Sha256: 3f71cd62707f1af462bb5cd5631439cdff63f46b2c8304cf5ae9e38629f03866

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Decidim
  module ProcessGroupsContentBlock
    module ContentBlocks
      class HighlightedProcessGroupsCell < Decidim::ViewModel
        include Decidim::SanitizeHelper

        delegate :current_organization, to: :controller
        delegate :current_user, to: :controller

        def show
          if highlighted_groups.any?
            render
          end
        end

        def highlighted_groups
          Decidim::ParticipatoryProcesses::OrganizationPrioritizedParticipatoryProcessGroups.new(
            current_organization
          ).query
          .joins(:participatory_processes)
          .where.not(decidim_participatory_processes: { published_at: nil })
          .where('decidim_participatory_processes.end_date > ?', DateTime.now)
          .group('decidim_participatory_process_groups.id')
          .having('COUNT(decidim_participatory_processes.id) > 0')
        end

        def i18n_scope
          "decidim.process_groups_content_block.pages.home.highlighted_process_groups"
        end

        def decidim_participatory_processes
          Decidim::ParticipatoryProcesses::Engine.routes.url_helpers
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-process_groups_content_block-0.16.0 app/cells/decidim/process_groups_content_block/content_blocks/highlighted_process_groups_cell.rb
decidim-process_groups_content_block-0.15.0 app/cells/decidim/process_groups_content_block/content_blocks/highlighted_process_groups_cell.rb