Sha256: 18543c719715b6225b9b883fd12617a0a716973f4a25026c4bf5f5bbcaf4bf3e

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Directory
      # Exposes the meeting resource so users can view them
      class MeetingsController < Decidim::ApplicationController
        layout "layouts/decidim/application"

        include FilterResource
        include Paginable

        helper Decidim::WidgetUrlsHelper
        helper Decidim::FiltersHelper
        helper Decidim::Meetings::MapHelper
        helper Decidim::ResourceHelper

        helper_method :meetings, :search

        def index
          @meeting_spaces = search.results.map do |meeting|
            klass = meeting.component.participatory_space.class
            [klass.model_name.name.underscore, klass.model_name.human.pluralize]
          end.uniq
          @meeting_spaces = @meeting_spaces.sort_by do |_param, name|
            name
          end
          @meeting_spaces = @meeting_spaces.prepend(["all", t(".all")])
        end

        private

        def meetings
          @meetings ||= paginate(search.results)
        end

        def search_klass
          MeetingSearch
        end

        def default_filter_params
          {
            date: "upcoming",
            search_text: "",
            scope_id: "",
            space: "all"
          }
        end

        def default_search_params
          {
            scope: Meeting.visible_meeting_for(current_user)
          }
        end

        def context_params
          { component: meeting_components, organization: current_organization }
        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

3 entries across 3 versions & 1 rubygems

Version Path
decidim-meetings-0.15.2 app/controllers/decidim/meetings/directory/meetings_controller.rb
decidim-meetings-0.15.1 app/controllers/decidim/meetings/directory/meetings_controller.rb
decidim-meetings-0.15.0 app/controllers/decidim/meetings/directory/meetings_controller.rb