La liste des événements d'un lieu est séparée en à venir et passés
This commit is contained in:
parent
736f8c4bae
commit
bc106e2250
@ -65,10 +65,20 @@
|
||||
</div>
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
|
||||
{% cache cache_timeout place_list user.is_authenticated object page_obj.number %}
|
||||
|
||||
{% cache cache_timeout place_list user.is_authenticated object page_obj.number past %}
|
||||
<div class="slide-buttons">
|
||||
{% if past %}
|
||||
<a href="{% url 'view_place' object.pk %}" role="button">Voir les événements à venir</a>
|
||||
{% else %}
|
||||
<a href="{% url 'view_place_past' object.pk 'past' %}" role="button">Voir les événements passés</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if object_list %}
|
||||
<h2>Événements du lieu</h2>
|
||||
{% if past %}
|
||||
<h2>Événements passés</h2>
|
||||
{% else %}
|
||||
<h2>Événements à venir</h2>
|
||||
{% endif %}
|
||||
|
||||
{% include "agenda_culturel/navigation.html" with page_obj=page_obj %}
|
||||
|
||||
|
@ -142,6 +142,7 @@ urlpatterns = [
|
||||
),
|
||||
path("404/", page_not_found, name="page_not_found"),
|
||||
path("500/", internal_server_error, name="internal_server_error"),
|
||||
path("place/<int:pk>/<past>", PlaceDetailView.as_view(), name="view_place_past"),
|
||||
path("place/<int:pk>", PlaceDetailView.as_view(), name="view_place"),
|
||||
path("place/<int:pk>/edit", PlaceUpdateView.as_view(), name="edit_place"),
|
||||
path("place/<int:pk>/delete", PlaceDeleteView.as_view(), name="delete_place"),
|
||||
|
@ -1725,11 +1725,18 @@ class PlaceDetailView(ListView):
|
||||
|
||||
def get_queryset(self):
|
||||
self.place = get_object_or_404(Place, pk=self.kwargs["pk"])
|
||||
return Event.objects.filter(exact_location=self.place).order_by("-start_day")
|
||||
logger.warning(self.kwargs)
|
||||
self.past = "past" in self.kwargs
|
||||
if self.past:
|
||||
return Event.objects.filter(exact_location=self.place).filter(start_day__lte=datetime.now()).order_by("-start_day")
|
||||
else:
|
||||
return Event.objects.filter(exact_location=self.place).filter(start_day__gte=datetime.now()).order_by("start_day")
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["object"] = self.place
|
||||
context["past"] = self.past
|
||||
return context
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user