Change recent session view to current year
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Lukáš Kucharczyk 2023-09-14 18:49:16 +02:00
parent e1655d6cfa
commit 0b7da3550c
2 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@
* Improve form appearance
* Add helper buttons next to datime fields
* Change recent session view to current year instead of last 30 days
## 1.0.3 / 2023-02-20 17:16+01:00

View File

@ -162,10 +162,12 @@ def list_sessions(
dataset = Session.objects.filter(purchase__ownership_type=ownership_type)
context["ownership_type"] = dict(Purchase.OWNERSHIP_TYPES)[ownership_type]
elif filter == "recent":
current_year = datetime.now().year
first_day_of_year = datetime(current_year, 1, 1)
dataset = Session.objects.filter(
timestamp_start__gte=datetime.now() - timedelta(days=30)
timestamp_start__gte=first_day_of_year
).order_by("-timestamp_start")
context["title"] = "Last 30 days"
context["title"] = "This year"
else:
# by default, sort from newest to oldest
dataset = Session.objects.all().order_by("-timestamp_start")