From dd7fe92aecec2d331976b7f1a6f3103c6d584ab6 Mon Sep 17 00:00:00 2001 From: Benjamin Cutler Date: Wed, 6 Dec 2023 14:17:53 -0700 Subject: [PATCH] * last second cleanup --- tests/apiv2/test_donations.py | 3 ++- tests/randgen.py | 4 +--- tracker/models/event.py | 10 +--------- tracker/models/prize.py | 4 ++-- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/apiv2/test_donations.py b/tests/apiv2/test_donations.py index ad81fa241..91788a3a7 100644 --- a/tests/apiv2/test_donations.py +++ b/tests/apiv2/test_donations.py @@ -1,5 +1,6 @@ import random from datetime import datetime, timedelta +from typing import Optional from django.contrib.admin.models import CHANGE from django.contrib.auth.models import Permission, User @@ -30,7 +31,7 @@ def generate_donations( count=1, state: str, transactionstate='COMPLETED', - time: datetime = None, + time: Optional[datetime] = None, ): commentstate = 'PENDING' readstate = 'PENDING' diff --git a/tests/randgen.py b/tests/randgen.py index 59e4564eb..a2594b17a 100644 --- a/tests/randgen.py +++ b/tests/randgen.py @@ -647,9 +647,7 @@ def build_random_event( event = generate_event(rand, start_time=start_time) if not start_time: - start_time = datetime.datetime.combine(event.date, datetime.time()).replace( - tzinfo=datetime.timezone.utc - ) + start_time = datetime.datetime.combine(event.date, utcnow().timetz()) event.save() list_of_runs = generate_runs(rand, event=event, num_runs=num_runs, scheduled=True) diff --git a/tracker/models/event.py b/tracker/models/event.py index e7f98dbbe..f17a19444 100644 --- a/tracker/models/event.py +++ b/tracker/models/event.py @@ -20,13 +20,6 @@ from .fields import TimestampField from .util import LatestEvent -# TODO: remove when 3.9 is oldest supported version - -try: - import zoneinfo -except ImportError: - from backports import zoneinfo - # TODO: remove when 3.10 is oldest supported version try: @@ -49,7 +42,6 @@ def pairwise(iterable): 'Headset', ] -_timezoneChoices = [(x, x) for x in zoneinfo.available_timezones()] _currencyChoices = (('USD', 'US Dollars'), ('CAD', 'Canadian Dollars')) @@ -401,7 +393,7 @@ def upcoming( elif isinstance(now, str): now = datetime.datetime.fromisoformat(now) elif isinstance(now, datetime.datetime): - now = now.astimezone(datetime.timezone.utc) + pass # no adjustment necessary else: raise ValueError(f'Expected None, str, or datetime, got {type(now)}') if include_current: diff --git a/tracker/models/prize.py b/tracker/models/prize.py index 9720918af..d4d999e49 100644 --- a/tracker/models/prize.py +++ b/tracker/models/prize.py @@ -423,9 +423,9 @@ def start_draw_time(self): return self.prev_run.endtime - datetime.timedelta( milliseconds=self.prev_run.setup_time_ms ) - return self.startrun.starttime.replace(tzinfo=datetime.timezone.utc) + return self.startrun.start_time_utc elif self.starttime: - return self.starttime.replace(tzinfo=datetime.timezone.utc) + return self.start_time_utc else: return None