From 1af267dc16b960b7db2849eccc801f13e3770b3b Mon Sep 17 00:00:00 2001 From: Benjamin Cutler Date: Wed, 6 Dec 2023 14:17:53 -0700 Subject: [PATCH] * last second cleanup --- setup.py | 2 +- tests/apiv2/test_donations.py | 3 ++- tests/randgen.py | 4 +--- tests/requirements.txt | 2 +- tracker/models/event.py | 10 +--------- tracker/models/prize.py | 4 ++-- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index 48fb4d302..96ce2d7d2 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ def get_package_name(name): 'celery~=5.0', 'channels>=2.0', 'Django>=3.2,!=4.0.*,<4.3', - 'django-ajax-selects~=2.2', + 'django-ajax-selects~=2.1', # publish error, see: https://github.com/crucialfelix/django-ajax-selects/issues/306 'django-ical~=1.7', 'django-mptt~=0.10', 'django-paypal~=1.1', 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/tests/requirements.txt b/tests/requirements.txt index c761416f3..dd298b7b4 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,7 +2,7 @@ celery==5.2.7 channels==3.0.4 # django explicitly not listed here because azure installs a particular series immediately after -django-ajax-selects==2.2.0 +django-ajax-selects==2.1.0 # publish error, see: https://github.com/crucialfelix/django-ajax-selects/issues/306 django-ical==1.9.2 django-paypal==1.1.2 django-mptt==0.14.0 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