Private
Public Access
1
0

fixes and additions

This commit is contained in:
2024-12-27 11:04:27 +01:00
parent c601af31c5
commit bc4c047ba0
5 changed files with 55 additions and 32 deletions

View File

@@ -109,7 +109,7 @@ import pyarrow as pa
from pyarrow.lib import ArrowInvalid
from django.utils import timezone
from django.utils import timezone as tz
from django.utils.timezone import get_current_timezone
from django.urls import reverse
import requests
@@ -276,7 +276,7 @@ def check_marker(workout):
def workout_summary_to_df(
rower,
startdate=datetime.datetime(1970, 1, 1),
enddate=timezone.now()+timezone.timedelta(days=1)):
enddate=tz.now()+tz.timedelta(days=1)):
ws = Workout.objects.filter(
user=rower, date__gte=startdate, date__lte=enddate,
@@ -636,7 +636,7 @@ def setcp(workout, background=False, recurrance=True):
def update_wps(r, types, mode='water', asynchron=True):
firstdate = timezone.now()-datetime.timedelta(days=r.cprange)
firstdate = tz.now()-datetime.timedelta(days=r.cprange)
workouts = Workout.objects.filter(
date__gte=firstdate,
workouttype__in=types,
@@ -702,7 +702,7 @@ def join_workouts(r, ids, title='Joined Workout',
notes = ''
summary = ''
makeprivate = False
startdatetime = timezone.now()
startdatetime = tz.now()
if setprivate is True and makeprivate is False: # pragma: no cover
makeprivate = True
@@ -801,7 +801,7 @@ def fetchcp_new(rower, workouts):
def update_rolling_cp(r, types, mode='water', dosend=False):
firstdate = timezone.now()-datetime.timedelta(days=r.cprange)
firstdate = tz.now()-datetime.timedelta(days=r.cprange)
workouts = Workout.objects.filter(
date__gte=firstdate,
workouttype__in=types,
@@ -1425,10 +1425,12 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
w.save()
except ValidationError: # pragma: no cover
try:
w.startdatetime = timezone.now()
w.startdatetime = tz.now()
w.save()
except ValidationError:
return (0, 'Unable to create your workout')
except AttributeError:
return (0, 'Unable to create your workout')
if privacy == 'visible':
ts = Team.objects.filter(rower=r)
@@ -1631,28 +1633,32 @@ def new_workout_from_file(r, f2,
startdatetime=startdatetime,
))
id, message = save_workout_database(
f2, r,
notes=notes,
workouttype=workouttype,
weightcategory=r.weightcategory,
adaptiveclass=r.adaptiveclass,
boattype=boattype,
makeprivate=makeprivate,
dosummary=dosummary,
workoutsource=workoutsource,
summary=summary,
startdatetime=startdatetime,
timezone=timezone,
rpe=rpe,
inboard=inboard, oarlength=oarlength,
seatnumber=seatnumber, boatname=boatname,
empowerside=empowerside,
title=title,
forceunit='N',
impeller=impeller,
workoutid=workoutid,
)
try:
id, message = save_workout_database(
f2, r,
notes=notes,
workouttype=workouttype,
weightcategory=r.weightcategory,
adaptiveclass=r.adaptiveclass,
boattype=boattype,
makeprivate=makeprivate,
dosummary=dosummary,
workoutsource=workoutsource,
summary=summary,
startdatetime=startdatetime,
timezone=timezone,
rpe=rpe,
inboard=inboard, oarlength=oarlength,
seatnumber=seatnumber, boatname=boatname,
empowerside=empowerside,
title=title,
forceunit='N',
impeller=impeller,
workoutid=workoutid,
)
except ValueError:
message = "error saving"
id = 0
return (id, message, f2)
@@ -1696,7 +1702,7 @@ def new_workout_from_df(r, df,
makeprivate = False
rpe = 0
if startdatetime == '': # pragma: no cover
startdatetime = timezone.now()
startdatetime = tz.now()
if setprivate: # pragma: no cover
makeprivate = True