workout split works
This commit is contained in:
@@ -860,20 +860,36 @@ def split_workout(r,parent,splitsecond,splitmode):
|
||||
ids = []
|
||||
|
||||
if 'keep first' in splitmode:
|
||||
if 'secondprivate' in splitmode:
|
||||
setprivate = True
|
||||
else:
|
||||
setprivate = False
|
||||
|
||||
id,message = new_workout_from_df(r,data1,
|
||||
title=parent.name+' First Part',
|
||||
parent=parent)
|
||||
parent=parent,
|
||||
setprivate=setprivate)
|
||||
messages.append(message)
|
||||
ids.append(id)
|
||||
if 'keep second' in splitmode:
|
||||
data2['cumdist'] = data2['cumdist'] - data2.ix[0,'cumdist']
|
||||
data2['distance'] = data2['distance'] - data2.ix[0,'distance']
|
||||
data2['time'] = data2['time'] - data2.ix[0,'time']
|
||||
if 'secondprivate' in splitmode:
|
||||
setprivate = True
|
||||
else:
|
||||
setprivate = False
|
||||
|
||||
dt = datetime.timedelta(seconds=splitsecond)
|
||||
|
||||
id,message = new_workout_from_df(r,data2,
|
||||
title=parent.name+' Second Part',
|
||||
parent=parent)
|
||||
parent=parent,
|
||||
setprivate=setprivate,
|
||||
dt=dt)
|
||||
messages.append(message)
|
||||
ids.append(id)
|
||||
|
||||
|
||||
if not 'keep original' in splitmode:
|
||||
if 'keep second' in splitmode or 'keep first' in splitmode:
|
||||
@@ -882,6 +898,9 @@ def split_workout(r,parent,splitsecond,splitmode):
|
||||
else:
|
||||
messages.append('That would delete your workout')
|
||||
ids.append(parent.id)
|
||||
elif 'originalprivate' in splitmode:
|
||||
parent.privacy = 'hidden'
|
||||
parent.save()
|
||||
|
||||
return ids,messages
|
||||
|
||||
@@ -890,7 +909,9 @@ def split_workout(r,parent,splitsecond,splitmode):
|
||||
# Currently there is code duplication
|
||||
def new_workout_from_df(r,df,
|
||||
title='New Workout',
|
||||
parent=None):
|
||||
parent=None,
|
||||
setprivate=False,
|
||||
dt=datetime.timedelta()):
|
||||
|
||||
message = None
|
||||
|
||||
@@ -902,7 +923,7 @@ def new_workout_from_df(r,df,
|
||||
notes=parent.notes
|
||||
summary=parent.summary
|
||||
makeprivate=parent.privacy
|
||||
startdatetime=parent.startdatetime
|
||||
startdatetime=parent.startdatetime+dt
|
||||
else:
|
||||
oarlength = 2.89
|
||||
inboard = 0.88
|
||||
@@ -912,6 +933,9 @@ def new_workout_from_df(r,df,
|
||||
makeprivate=False
|
||||
startdatetime = timezone.now()
|
||||
|
||||
if setprivate:
|
||||
makeprivate=True
|
||||
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
|
||||
csvfilename ='media/df_'+timestr+'.csv'
|
||||
@@ -921,7 +945,7 @@ def new_workout_from_df(r,df,
|
||||
|
||||
starttimeunix = mktime(startdatetime.utctimetuple())
|
||||
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
||||
print df[' ElapsedTime (sec)'].values
|
||||
|
||||
df['TimeStamp (sec)'] = df['TimeStamp (sec)']+starttimeunix
|
||||
|
||||
row = rrdata(df=df)
|
||||
|
||||
Reference in New Issue
Block a user