attaching workout to planned session
This commit is contained in:
@@ -208,6 +208,7 @@ from django.core.cache import cache
|
||||
from django_mailbox.models import Message,Mailbox,MessageAttachment
|
||||
|
||||
|
||||
|
||||
# Utility to get stroke data in a JSON response
|
||||
class JSONResponse(HttpResponse):
|
||||
def __init__(self, data, **kwargs):
|
||||
@@ -3369,6 +3370,11 @@ def addmanual_view(request):
|
||||
avghr = metricsform.cleaned_data['avghr']
|
||||
avgpwr = metricsform.cleaned_data['avgpwr']
|
||||
avgspm = metricsform.cleaned_data['avgspm']
|
||||
try:
|
||||
ps = form.cleaned_data['plannedsession']
|
||||
except KeyError:
|
||||
ps = None
|
||||
|
||||
try:
|
||||
boattype = request.POST['boattype']
|
||||
except KeyError:
|
||||
@@ -3426,10 +3432,14 @@ def addmanual_view(request):
|
||||
w.privacy = privacy
|
||||
w.weightcategory = weightcategory
|
||||
w.notes = notes
|
||||
w.plannedsession = ps
|
||||
w.name = name
|
||||
w.workouttype = workouttype
|
||||
w.boattype = boattype
|
||||
w.save()
|
||||
if ps:
|
||||
add_workouts_plannedsession([w],ps,w.user)
|
||||
|
||||
messages.info(request,'New workout created')
|
||||
else:
|
||||
return render(request,'manualadd.html',
|
||||
@@ -9969,7 +9979,12 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
private = form.cleaned_data['private']
|
||||
notes = form.cleaned_data['notes']
|
||||
thetimezone = form.cleaned_data['timezone']
|
||||
|
||||
|
||||
try:
|
||||
ps = form.cleaned_data['plannedsession']
|
||||
except KeyError:
|
||||
ps = None
|
||||
|
||||
try:
|
||||
boattype = request.POST['boattype']
|
||||
except KeyError:
|
||||
@@ -10031,10 +10046,17 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
row.privacy = privacy
|
||||
row.rankingpiece = rankingpiece
|
||||
row.timezone = thetimezone
|
||||
row.plannedsession = ps
|
||||
|
||||
try:
|
||||
row.save()
|
||||
except IntegrityError:
|
||||
pass
|
||||
|
||||
if ps:
|
||||
add_workouts_plannedsession([row],ps,row.user)
|
||||
|
||||
|
||||
# change data in csv file
|
||||
|
||||
r = rdata(row.csvfilename)
|
||||
|
||||
Reference in New Issue
Block a user