Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2022-04-07 12:14:47 +02:00
parent 19dcd01143
commit 084e384aaa
3 changed files with 104 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ from rowers.views.statements import *
import rowers.garmin_stuff as gs
from rowers import credits
from json.decoder import JSONDecodeError
from rowers.utils import step_to_string
@login_required
@@ -3013,6 +3014,40 @@ def stepadder(request, id=0):
redirect_field_name=None)
def stepeditor(request, id=0):
ps = get_object_or_404(PlannedSession, pk=id)
if ps.steps:
for step in ps.steps['steps']:
print(step)
durationtype = step.get('durationType','')
durationvalue = step.get('durationValue',0)
targetvalue = step.get('targetValue',0)
targettype = step.get('targetType','')
targetvaluelow = step.get('targetValueLow',0)
targetvaluehigh = step.get('targetValueHigh',0)
intensity = step.get('intensity','Active')
archived_steps = PlannedSessionStep.objects.filter(
manager = request.user,
durationtype = durationtype,
durationvalue = durationvalue,
targetvalue = targetvalue,
targettype = targettype,
targetvaluelow = targetvaluelow,
targetvaluehigh = targetvaluehigh,
intensity = intensity,
).count()
if not archived_steps and durationvalue != 0:
s = PlannedSessionStep(
manager = request.user,
durationtype = durationtype,
durationvalue = durationvalue,
targetvalue = targetvalue,
targettype = targettype,
targetvaluelow = targetvaluelow,
targetvaluehigh = targetvaluehigh,
intensity = intensity,
name = step.get('wkt_step_name','Step')
)
s.save()
ps.steps = {}
@@ -3028,9 +3063,20 @@ def stepeditor(request, id=0):
steps = PlannedSessionStep.objects.filter(manager=request.user)
stepdescriptions = {}
for step in steps:
stepdescriptions[step.id] = step_to_string(step.asdict(), short=False)[0]
print(stepdescriptions)
print(steps)
return render(request, 'stepeditor.html',
{
'steps':steps,
'stepdescriptions': stepdescriptions,
'form':form,
'ps':ps,
})