Private
Public Access
1
0

making upload options sticky and adding make private

This commit is contained in:
Sander Roosendaal
2017-02-15 16:16:02 +01:00
parent 154619a0dc
commit 5deaa194f0
3 changed files with 57 additions and 14 deletions

View File

@@ -228,7 +228,8 @@ def timedeltaconv(x):
# Processes painsled CSV file to database
def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
dosummary=True,title='Workout',
notes='',totaldist=0,totaltime=0):
notes='',totaldist=0,totaltime=0,
makeprivate=False):
message = None
powerperc = 100*np.array([r.pw_ut2,
r.pw_ut1,
@@ -313,12 +314,18 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
workoutstarttime = row.rowdatetime.strftime('%H:%M:%S')
workoutstartdatetime = thetimezone.localize(row.rowdatetime).astimezone(utc)
if makeprivate:
privacy = 'private'
else:
privacy = 'visible'
# check for duplicate start times
ws = Workout.objects.filter(starttime=workoutstarttime,
user=r)
if (len(ws) != 0):
message = "Warning: This workout probably already exists in the database"
w = Workout(user=r,name=title,date=workoutdate,
workouttype=workouttype,
duration=duration,distance=totaldist,
@@ -326,15 +333,16 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
starttime=workoutstarttime,
csvfilename=f2,notes=notes,summary=summary,
maxhr=maxhr,averagehr=averagehr,
startdatetime=workoutstartdatetime)
startdatetime=workoutstartdatetime,
privacy=privacy)
w.save()
ts = Team.objects.filter(rower=r)
for t in ts:
w.team.add(t)
if privacy == 'visible':
ts = Team.objects.filter(rower=r)
for t in ts:
w.team.add(t)
# put stroke data in database
res = dataprep(row.df,id=w.id,bands=True,
@@ -422,6 +430,7 @@ def handle_nonpainsled(f2,fileformat,summary=''):
def new_workout_from_file(r,f2,
workouttype='rower',
title='Workout',
makeprivate=False,
notes=''):
message = None
fileformat = get_file_type(f2)
@@ -470,6 +479,7 @@ def new_workout_from_file(r,f2,
dosummary = (fileformat != 'fit')
id,message = save_workout_database(f2,r,
workouttype=workouttype,
makeprivate=makeprivate,
dosummary=dosummary,
title=title)