Apply review comments

This commit is contained in:
Antoine Bartuccio 2025-02-25 18:28:16 +01:00
parent a01ea13f5b
commit a653f98fc1

View File

@ -261,15 +261,13 @@ class NewsListView(TemplateView):
D on 20/03, E on 21/03 and F on 22/03 ; D on 20/03, E on 21/03 and F on 22/03 ;
then the result is 20/03. then the result is 20/03.
""" """
try: dates = list(
return list( NewsDate.objects.filter(end_date__gt=now())
NewsDate.objects.filter(end_date__gt=now()) .order_by("start_date")
.order_by("start_date") .values_list("start_date__date", flat=True)
.values_list("start_date__date", flat=True) .distinct()[:4]
.distinct()[:4] )
)[-1] return dates[-1] if len(dates) > 0 else None
except IndexError:
return None
def get_news_dates(self, until: date) -> dict[date, list[date]]: def get_news_dates(self, until: date) -> dict[date, list[date]]:
"""Return the event dates to display. """Return the event dates to display.