Sha256: d00baac08e2beb133150c71b8ba3680e6df819077169d52752020f93f3adb2b3

Contents?: true

Size: 1.36 KB

Versions: 12

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # Exposes the meeting resource so users can view them
    class MeetingsController < Decidim::Meetings::ApplicationController
      include FilterResource

      helper Decidim::WidgetUrlsHelper

      helper_method :meetings, :geocoded_meetings, :meeting

      def index
        return unless search.results.empty? && params.dig("filter", "date") != "past"

        @past_meetings = search_klass.new(search_params.merge(date: "past"))
        unless @past_meetings.results.empty?
          params[:filter] ||= {}
          params[:filter][:date] = "past"
          @forced_past_meetings = true
          @search = @past_meetings
        end
      end

      private

      def meeting
        @meeting ||= Meeting.where(feature: current_feature).find(params[:id])
      end

      def meetings
        @meetings ||= search.results.page(params[:page]).per(12)
      end

      def geocoded_meetings
        @geocoded_meetings ||= search.results.select(&:geocoded?)
      end

      def search_klass
        MeetingSearch
      end

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

      def context_params
        { feature: current_feature, organization: current_organization }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
decidim-meetings-0.4.0 app/controllers/decidim/meetings/meetings_controller.rb
decidim-0.4.0 decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb
decidim-meetings-0.3.2 app/controllers/decidim/meetings/meetings_controller.rb
decidim-0.3.2 decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb
decidim-meetings-0.3.1 app/controllers/decidim/meetings/meetings_controller.rb
decidim-0.3.1 decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb
decidim-meetings-0.3.0 app/controllers/decidim/meetings/meetings_controller.rb
decidim-0.3.0 decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb
decidim-meetings-0.2.0 app/controllers/decidim/meetings/meetings_controller.rb
decidim-0.2.0 decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb
decidim-meetings-0.1.0 app/controllers/decidim/meetings/meetings_controller.rb
decidim-0.1.0 decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb