Improve time-related stuff
Add created_at to all models Add modified_at to Session Get rid of custom now() function Make sure aware datetime is used everywhere
This commit is contained in:
parent
51ba5cfa20
commit
978714125b
|
@ -1,7 +1,6 @@
|
||||||
from common.time import format_duration
|
from common.time import format_duration
|
||||||
from common.utils import safe_division
|
from common.utils import safe_division
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from django.conf import settings
|
|
||||||
from django.db.models import Sum, F, Count, Prefetch
|
from django.db.models import Sum, F, Count, Prefetch
|
||||||
from django.db.models.functions import TruncDate
|
from django.db.models.functions import TruncDate
|
||||||
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
|
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
|
||||||
|
@ -9,7 +8,6 @@ from django.shortcuts import redirect, render
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from typing import Callable, Any
|
from typing import Callable, Any
|
||||||
from zoneinfo import ZoneInfo
|
|
||||||
|
|
||||||
from .forms import (
|
from .forms import (
|
||||||
GameForm,
|
GameForm,
|
||||||
|
@ -279,7 +277,7 @@ 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
|
current_year = timezone.now().year
|
||||||
first_day_of_year = datetime(current_year, 1, 1)
|
first_day_of_year = datetime(current_year, 1, 1)
|
||||||
dataset = Session.objects.filter(
|
dataset = Session.objects.filter(
|
||||||
timestamp_start__gte=first_day_of_year
|
timestamp_start__gte=first_day_of_year
|
||||||
|
|
Loading…
Reference in New Issue