Change recent session view to current year
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
e1655d6cfa
commit
0b7da3550c
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
* Improve form appearance
|
* Improve form appearance
|
||||||
* Add helper buttons next to datime fields
|
* 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
|
## 1.0.3 / 2023-02-20 17:16+01:00
|
||||||
|
|
||||||
|
|
|
@ -162,10 +162,12 @@ def list_sessions(
|
||||||
dataset = Session.objects.filter(purchase__ownership_type=ownership_type)
|
dataset = Session.objects.filter(purchase__ownership_type=ownership_type)
|
||||||
context["ownership_type"] = dict(Purchase.OWNERSHIP_TYPES)[ownership_type]
|
context["ownership_type"] = dict(Purchase.OWNERSHIP_TYPES)[ownership_type]
|
||||||
elif filter == "recent":
|
elif filter == "recent":
|
||||||
|
current_year = datetime.now().year
|
||||||
|
first_day_of_year = datetime(current_year, 1, 1)
|
||||||
dataset = Session.objects.filter(
|
dataset = Session.objects.filter(
|
||||||
timestamp_start__gte=datetime.now() - timedelta(days=30)
|
timestamp_start__gte=first_day_of_year
|
||||||
).order_by("-timestamp_start")
|
).order_by("-timestamp_start")
|
||||||
context["title"] = "Last 30 days"
|
context["title"] = "This year"
|
||||||
else:
|
else:
|
||||||
# by default, sort from newest to oldest
|
# by default, sort from newest to oldest
|
||||||
dataset = Session.objects.all().order_by("-timestamp_start")
|
dataset = Session.objects.all().order_by("-timestamp_start")
|
||||||
|
|
Loading…
Reference in New Issue