diff --git a/rowers/dataprep.py b/rowers/dataprep.py index f99a9468..d8002909 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -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 diff --git a/rowers/templates/team_compare_select.html b/rowers/templates/team_compare_select.html index 3a7dd211..176f5c69 100644 --- a/rowers/templates/team_compare_select.html +++ b/rowers/templates/team_compare_select.html @@ -146,7 +146,7 @@
Warning: You are on an experimental part of the site. Use at your own risk.
Select two or more workouts on the left, set your plot settings below, - and press submit"
+ and press submit {% csrf_token %}