decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb in decidim-0.0.5 vs decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb in decidim-0.0.6
- old
+ new
@@ -6,28 +6,33 @@
class MeetingsController < Decidim::Meetings::ApplicationController
include FilterResource
helper_method :meetings, :geocoded_meetings, :meeting
- def index; end
-
- def static_map
- @meeting = Meeting.where(feature: current_feature).find(params[:id])
- send_data StaticMapGenerator.new(@meeting).data, type: "image/jpeg", disposition: "inline"
+ def index
+ if 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
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 meeting
- @meeting ||= Meeting.where(feature: current_feature).find(params[:id])
end
def search_klass
MeetingSearch
end