poc vue jour

This commit is contained in:
SebF 2024-05-06 17:05:54 +02:00
parent 1a52d02141
commit 7b3aca21f4
3 changed files with 24 additions and 0 deletions

View File

@ -94,7 +94,10 @@
<header>
<h2>Voir aussi</h2>
</header>
<div class="buttons">
<a role="button" href="{% url 'export_events_ical' day.year day.month day.day%}" >Exporter ical {% picto_from_name "calendar" %}</a>
<a role="button" href="{% url 'week_view' day.year day|week %}?{{ filter.get_url }}">Toute la semaine</a>
</div>
</article>
</aside>

View File

@ -159,6 +159,11 @@ urlpatterns = [
name="add_place_to_event",
),
path("event/<int:pk>", export_event_ical, name="export_event_ical"),
path(
"events/<int:year>/<int:month>/<int:day>",
export_events_ical,
name="export_events_ical",
),
]
if settings.DEBUG:

View File

@ -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