diff --git a/setup.py b/setup.py index 48fb4d302..fc04f739c 100644 --- a/setup.py +++ b/setup.py @@ -53,14 +53,14 @@ 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', 'django-post-office~=3.2', 'django-timezone-field>=3.1,<7.0', 'djangorestframework~=3.9', - 'python-dateutil~=2.8.1', # TODO: remove when 3.11 is oldest supported version + 'python-dateutil~=2.8.1;python_version<"3.11"', 'requests>=2.27.1,<2.32.0', ], python_requires='>=3.7, <3.12', 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..3fa07b0db 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 @@ -10,8 +10,7 @@ django-post-office==3.6.0 django-timezone-field==6.1.0 djangorestframework==3.14.0 backports.zoneinfo==0.2.1 ; python_version<"3.9" -# TODO: can be removed when 3.11 is oldest supported version -python-dateutil==2.8.2 +python-dateutil==2.8.2 ; python_version<"3.11" # can be removed when either 3.7 is not supported or once we upgrade Celery importlib_metadata==4.13.0 ; python_version<"3.8" pre-commit==3.5.0 ; python_version>="3.8" 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