join working but needs improvement (form with title)
This commit is contained in:
@@ -158,6 +158,69 @@ def filter_df(datadf, fieldname, value, largerthan=True):
|
||||
|
||||
return datadf
|
||||
|
||||
# joins workouts
|
||||
def join_workouts(r,ids,title='Joined Workout',
|
||||
parent=None,
|
||||
setprivate=False,
|
||||
forceunit='lbs'):
|
||||
|
||||
message = None
|
||||
|
||||
summary = ''
|
||||
if parent:
|
||||
oarlength = parent.oarlength
|
||||
inboard = parent.inboard
|
||||
workouttype = parent.workouttype
|
||||
notes = parent.notes
|
||||
summary = parent.summary
|
||||
if parent.privacy == 'hidden':
|
||||
makeprivate = True
|
||||
else:
|
||||
makeprivate = False
|
||||
|
||||
startdatetime = parent.startdatetime
|
||||
else:
|
||||
oarlength = 2.89
|
||||
inboard = 0.88
|
||||
workouttype = 'rower'
|
||||
notes = ''
|
||||
summary = ''
|
||||
makeprivate = False
|
||||
startdatetime = timezone.now()
|
||||
|
||||
if setprivate:
|
||||
makeprivate = True
|
||||
|
||||
# reorder in chronological order
|
||||
ws = Workout.objects.filter(id__in=ids).order_by("date", "starttime")
|
||||
files = [w.csvfilename for w in ws]
|
||||
|
||||
row = rdata(files[0])
|
||||
|
||||
files = files[1:]
|
||||
|
||||
while len(files):
|
||||
row2 = rdata(files[0])
|
||||
if row2 != 0:
|
||||
row = row+row2
|
||||
files = files[1:]
|
||||
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
csvfilename = 'media/df_' + timestr + '.csv'
|
||||
|
||||
row.write_csv(csvfilename,gzip=True)
|
||||
id, message = save_workout_database(csvfilename, r,
|
||||
workouttype=workouttype,
|
||||
title=title,
|
||||
notes=notes,
|
||||
oarlength=oarlength,
|
||||
inboard=inboard,
|
||||
makeprivate=makeprivate,
|
||||
dosmooth=False,
|
||||
consistencychecks=False)
|
||||
|
||||
return (id, message)
|
||||
|
||||
|
||||
def df_resample(datadf):
|
||||
# time stamps must be in seconds
|
||||
|
||||
Reference in New Issue
Block a user