old goals will automatically be deactivated
This commit is contained in:
@@ -1917,10 +1917,26 @@ def rower_create_trainingplan(request,userid=0):
|
||||
rowers=therower,
|
||||
date__gte=datetime.date.today(),
|
||||
).order_by("date")
|
||||
|
||||
old_targets = TrainingTarget.objects.filter(
|
||||
rowers=therower,
|
||||
date__lt=datetime.date.today(),
|
||||
).order_by("-date")
|
||||
|
||||
targetform = TrainingTargetForm(user=request.user)
|
||||
|
||||
plans = TrainingPlan.objects.filter(rowers=therower).order_by("-startdate")
|
||||
|
||||
plans_to_deactivate = TrainingPlan.objects.filter(
|
||||
rowers=therower,
|
||||
enddate__lt=datetime.date.today(),
|
||||
status=True,
|
||||
).order_by("-startdate")
|
||||
|
||||
for p in plans_to_deactivate:
|
||||
p.status = False
|
||||
p.save()
|
||||
|
||||
|
||||
form = TrainingPlanForm(targets=targets,
|
||||
initial={'status':False,'rowers':[therower]},
|
||||
@@ -1949,6 +1965,7 @@ def rower_create_trainingplan(request,userid=0):
|
||||
'active':'nav-plan',
|
||||
'targets':targets,
|
||||
'targetform':targetform,
|
||||
'old_targets':old_targets,
|
||||
})
|
||||
|
||||
@user_passes_test(hasplannedsessions,login_url="/rowers/paidplans",
|
||||
|
||||
Reference in New Issue
Block a user