From ec406e5c074cbed4347eb6b4bc09ceda6054f79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Genevi=C3=A8ve=20Bastien?= Date: Fri, 2 Sep 2016 21:41:11 -0400 Subject: [PATCH] events: allow rss feeds to show all events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RSS feeds can be easily parsed and hence can be used to populate program for events with the proper tags. By adding the 'showall=true' to the query string, it is possible to see all events corresponding to the requested criteria in the RSS feed, whether past or future and more than 20. Signed-off-by: Geneviève Bastien --- app/controllers/events_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 7a022609..3dd41826 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -15,7 +15,7 @@ class EventsController < ApplicationController respond_to do |format| format.html format.json { @events = @events.future } - format.rss { @events = @events.future.order('id desc').limit 20 } + format.rss { @events = filter_for_rss } format.ics { @events = @events.last_year } format.xml end @@ -107,6 +107,14 @@ class EventsController < ApplicationController :contact, :submitter, :tags end + def filter_for_rss + if(!params.has_key?(:showall)) + @events.future.order('id desc').limit 20 + else + @events.order('id desc') + end + end + def locked redirect_to edit_event_url(@event, secret: @event.secret), alert: t('staleObjectError')