Sha256: a5eb6dda762883ff601b1a50992faa6aed61b75ce278c9319f1d3556a77810ee

Contents?: true

Size: 1.62 KB

Versions: 7

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module ContentBlocks
      class UpcomingMeetingsCell < Decidim::ViewModel
        include Decidim::CardHelper

        def show
          return if upcoming_meetings.blank?

          render
        end

        def upcoming_meetings
          @upcoming_meetings ||= Decidim::Meetings::Meeting
                                 .includes(:author, component: :participatory_space)
                                 .where(component: meeting_components)
                                 .visible_for(current_user)
                                 .published
                                 .where("end_time >= ?", Time.current)
                                 .except_withdrawn
                                 .not_hidden
                                 .order(start_time: :asc)
                                 .limit(limit)
        end

        def geolocation_enabled?
          Decidim::Map.available?(:geocoding)
        end

        def meetings_directory_path
          Decidim::Meetings::DirectoryEngine.routes.url_helpers.root_path
        end

        private

        def limit
          geolocation_enabled? ? 4 : 8
        end

        def meeting_components
          @meeting_components ||= Decidim::Component
                                  .where(manifest_name: "meetings")
                                  .where(participatory_space: participatory_spaces)
                                  .published
        end

        def participatory_spaces
          @participatory_spaces ||= current_organization.public_participatory_spaces
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-meetings-0.27.4 app/cells/decidim/meetings/content_blocks/upcoming_meetings_cell.rb
decidim-meetings-0.27.3 app/cells/decidim/meetings/content_blocks/upcoming_meetings_cell.rb
decidim-meetings-0.27.2 app/cells/decidim/meetings/content_blocks/upcoming_meetings_cell.rb
decidim-meetings-0.27.1 app/cells/decidim/meetings/content_blocks/upcoming_meetings_cell.rb
decidim-meetings-0.27.0 app/cells/decidim/meetings/content_blocks/upcoming_meetings_cell.rb
decidim-meetings-0.27.0.rc2 app/cells/decidim/meetings/content_blocks/upcoming_meetings_cell.rb
decidim-meetings-0.27.0.rc1 app/cells/decidim/meetings/content_blocks/upcoming_meetings_cell.rb