Skip to content

Commit

Permalink
* last second cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
uraniumanchor committed Dec 6, 2023
1 parent ec8f12f commit dd7fe92
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
3 changes: 2 additions & 1 deletion tests/apiv2/test_donations.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -30,7 +31,7 @@ def generate_donations(
count=1,
state: str,
transactionstate='COMPLETED',
time: datetime = None,
time: Optional[datetime] = None,
):
commentstate = 'PENDING'
readstate = 'PENDING'
Expand Down
4 changes: 1 addition & 3 deletions tests/randgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 1 addition & 9 deletions tracker/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -49,7 +42,6 @@ def pairwise(iterable):
'Headset',
]

_timezoneChoices = [(x, x) for x in zoneinfo.available_timezones()]
_currencyChoices = (('USD', 'US Dollars'), ('CAD', 'Canadian Dollars'))


Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tracker/models/prize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dd7fe92

Please sign in to comment.