diff --git a/src/agenda_culturel/templates/agenda_culturel/page-day.html b/src/agenda_culturel/templates/agenda_culturel/page-day.html index 0348b3f..f830163 100644 --- a/src/agenda_culturel/templates/agenda_culturel/page-day.html +++ b/src/agenda_culturel/templates/agenda_culturel/page-day.html @@ -94,7 +94,10 @@

Voir aussi

+
+ Exporter ical {% picto_from_name "calendar" %} Toute la semaine +
diff --git a/src/agenda_culturel/urls.py b/src/agenda_culturel/urls.py index 9ff32f5..d8b7d81 100644 --- a/src/agenda_culturel/urls.py +++ b/src/agenda_culturel/urls.py @@ -159,6 +159,11 @@ urlpatterns = [ name="add_place_to_event", ), path("event/", export_event_ical, name="export_event_ical"), + path( + "events///", + export_events_ical, + name="export_events_ical", + ), ] if settings.DEBUG: diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index fb56d95..251ff70 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -615,6 +615,22 @@ def export_event_ical(request, pk): return response +def export_events_ical(request, year, month, day): + cday = CalendarDay(date(year, month, day)) + + events = cday.get_events() + + cal = Event.export_to_ics(events) + + response = HttpResponse(content_type="text/calendar") + response.content = cal.to_ical().decode("utf-8").replace("\r\n", "\n") + response["Content-Disposition"] = "attachment; filename={0}{1}".format( + "tutu", ".ics" + ) + + return response + + class EventFilterAdmin(django_filters.FilterSet): status = django_filters.MultipleChoiceFilter( choices=Event.STATUS.choices, widget=forms.CheckboxSelectMultiple