Compare commits
2 Commits
59d93cf686
...
7b3aca21f4
Author | SHA1 | Date | |
---|---|---|---|
7b3aca21f4 | |||
1a52d02141 |
@ -94,7 +94,10 @@
|
|||||||
<header>
|
<header>
|
||||||
<h2>Voir aussi</h2>
|
<h2>Voir aussi</h2>
|
||||||
</header>
|
</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>
|
<a role="button" href="{% url 'week_view' day.year day|week %}?{{ filter.get_url }}">Toute la semaine</a>
|
||||||
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
@ -159,6 +159,11 @@ urlpatterns = [
|
|||||||
name="add_place_to_event",
|
name="add_place_to_event",
|
||||||
),
|
),
|
||||||
path("event/<int:pk>", export_event_ical, name="export_event_ical"),
|
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:
|
if settings.DEBUG:
|
||||||
|
@ -10,7 +10,7 @@ from django.http import QueryDict
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.postgres.search import SearchQuery, SearchHeadline
|
from django.contrib.postgres.search import SearchQuery, SearchHeadline
|
||||||
|
|
||||||
from django.http import HttpResponseRedirect, FileResponse
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
@ -606,13 +606,30 @@ def export_event_ical(request, pk):
|
|||||||
|
|
||||||
cal = Event.export_to_ics(events)
|
cal = Event.export_to_ics(events)
|
||||||
|
|
||||||
return FileResponse(
|
response = HttpResponse(content_type="text/calendar")
|
||||||
cal.to_ical().decode("utf-8").replace("\r\n", "\n"),
|
response.content = cal.to_ical().decode("utf-8").replace("\r\n", "\n")
|
||||||
as_attachment=True,
|
response["Content-Disposition"] = "attachment; filename={0}{1}".format(
|
||||||
filename=event.title + ".ics",
|
event.title, ".ics"
|
||||||
content_type="text/calendar",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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):
|
class EventFilterAdmin(django_filters.FilterSet):
|
||||||
status = django_filters.MultipleChoiceFilter(
|
status = django_filters.MultipleChoiceFilter(
|
||||||
|
Loading…
Reference in New Issue
Block a user