parent
03a35065f6
commit
48d87f6498
@ -67,6 +67,7 @@
|
||||
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
|
||||
{% cache cache_timeout organisation_list user.is_authenticated object page_obj.number past %}
|
||||
<div class="slide-buttons">
|
||||
<a href="{% url 'export_ical_organisation' object.pk %}" role="button">Ajouter l'agenda {% picto_from_name "calendar" %}</a>
|
||||
{% if past %}
|
||||
<a href="{{ object.get_absolute_url }}" role="button">Voir les événements à venir</a>
|
||||
{% else %}
|
||||
|
@ -96,6 +96,7 @@
|
||||
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
|
||||
{% cache cache_timeout place_list user.is_authenticated object page_obj.number past %}
|
||||
<div class="slide-buttons">
|
||||
<a href="{% url 'export_ical_place' object.pk %}" role="button">Ajouter l'agenda {% picto_from_name "calendar" %}</a>
|
||||
{% if past %}
|
||||
<a href="{{ object.get_absolute_url }}" role="button">Voir les événements à venir</a>
|
||||
{% else %}
|
||||
|
@ -76,6 +76,7 @@
|
||||
</article>
|
||||
<div>
|
||||
<div class="slide-buttons">
|
||||
<a href="{% url 'export_ical_tag' tag|prepare_tag %}" role="button">Ajouter l'agenda {% picto_from_name "calendar" %}</a>
|
||||
{% if past %}
|
||||
<a href="{% url 'view_tag' tag|prepare_tag %}" role="button">Voir les événements à venir</a>
|
||||
{% else %}
|
||||
|
@ -176,6 +176,7 @@ urlpatterns = [
|
||||
path("cette-semaine/", week_view, name="cette_semaine"),
|
||||
path("ce-mois-ci", month_view, name="ce_mois_ci"),
|
||||
path("tag/<t>/", view_tag, name="view_tag"),
|
||||
path("tag/<tag>/ical", export_ical, name="export_ical_tag"),
|
||||
path("tag/<t>/past", view_tag_past, name="view_tag_past"),
|
||||
path("tags/", tag_list, name="view_all_tags"),
|
||||
path("tag/<int:pk>/edit", TagUpdateView.as_view(), name="edit_tag"),
|
||||
@ -361,6 +362,11 @@ urlpatterns = [
|
||||
OrganisationDetailView.as_view(),
|
||||
name="view_organisation_shortname",
|
||||
),
|
||||
path(
|
||||
"organisme/<int:organisation_pk>/ical",
|
||||
export_ical,
|
||||
name="export_ical_organisation",
|
||||
),
|
||||
path(
|
||||
"organisme/<int:pk>-<extra>",
|
||||
OrganisationDetailView.as_view(),
|
||||
@ -402,6 +408,7 @@ urlpatterns = [
|
||||
name="view_place_past",
|
||||
),
|
||||
path("place/<int:pk>", PlaceDetailView.as_view(), name="view_place"),
|
||||
path("place/<int:place_pk>/ical", export_ical, name="export_ical_place"),
|
||||
path(
|
||||
"place/<int:pk>-<extra>/past",
|
||||
PlaceDetailViewPast.as_view(),
|
||||
|
@ -1050,7 +1050,7 @@ def export_event_ical(request, year, month, day, pk):
|
||||
return response
|
||||
|
||||
|
||||
def export_ical(request, cat=None):
|
||||
def export_ical(request, cat=None, tag=None, organisation_pk=None, place_pk=None):
|
||||
now = date.today()
|
||||
|
||||
qs = get_event_qs(request)
|
||||
@ -1060,6 +1060,13 @@ def export_ical(request, cat=None):
|
||||
else:
|
||||
category = None
|
||||
|
||||
if place_pk is not None:
|
||||
qs = qs.filter(exact_location=place_pk)
|
||||
if organisation_pk is not None:
|
||||
qs = qs.filter(organisers__in=[organisation_pk])
|
||||
if tag is not None:
|
||||
qs = qs.filter(tags__in=[tag])
|
||||
|
||||
request = EventFilter.set_default_values(request)
|
||||
filter = EventFilter(request.GET, queryset=qs, request=request)
|
||||
|
||||
@ -1082,6 +1089,20 @@ def export_ical(request, cat=None):
|
||||
extra = ""
|
||||
if category is not None:
|
||||
extra += " " + category
|
||||
if place_pk is not None:
|
||||
extra += (
|
||||
" @ " + Place.objects.filter(pk=place_pk).values("name").first()["name"]
|
||||
)
|
||||
if organisation_pk is not None:
|
||||
extra += (
|
||||
" - "
|
||||
+ Organisation.objects.filter(pk=organisation_pk)
|
||||
.values("name")
|
||||
.first()["name"]
|
||||
)
|
||||
if tag is not None:
|
||||
extra += " - " + emoji.replace_emoji(tag, replace="")
|
||||
|
||||
response["Content-Disposition"] = "attachment; filename={0}{1}{2}".format(
|
||||
"Pommes de lune", extra, ".ics"
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user