fixed team session coach view
This commit is contained in:
@@ -42,8 +42,8 @@ def add_workouts_plannedsession(ws,ps,r):
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result,comments,errors
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
wold = Workout.objects.filter(plannedsession=ps,user=r)
|
||||
ids = [w.id for w in wold] + [w.id for w in ws]
|
||||
ids = list(set(ids))
|
||||
@@ -51,7 +51,7 @@ def add_workouts_plannedsession(ws,ps,r):
|
||||
if len(ids)>1 and ps.sessiontype in ['test','coursetest']:
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result,comments,errors
|
||||
|
||||
|
||||
# start adding sessions
|
||||
for w in ws:
|
||||
if w.date>=ps.startdate and w.date<=ps.enddate:
|
||||
@@ -63,7 +63,7 @@ def add_workouts_plannedsession(ws,ps,r):
|
||||
errors.append('Workout %i did not match session dates' % w.id)
|
||||
|
||||
return result,comments,errors
|
||||
|
||||
|
||||
|
||||
def remove_workout_plannedsession(w,ps):
|
||||
if w.plannedsession == ps:
|
||||
@@ -98,7 +98,7 @@ def get_session_metrics(ps):
|
||||
status = []
|
||||
|
||||
for r in rowers:
|
||||
rscorev = 0
|
||||
rscorev = 0
|
||||
trimpv = 0
|
||||
durationv = 0
|
||||
distancev = 0
|
||||
@@ -113,7 +113,7 @@ def get_session_metrics(ps):
|
||||
durationv += timefield_to_seconds_duration(w.duration)
|
||||
trimpv += dataprep.workout_trimp(w)
|
||||
rscorev += dataprep.workout_rscore(w)[0]
|
||||
|
||||
|
||||
ratio,statusv,completiondate = is_session_complete_ws(ws,ps)
|
||||
try:
|
||||
completedatev = completiondate.strftime('%Y-%m-%d')
|
||||
@@ -139,7 +139,7 @@ def get_session_metrics(ps):
|
||||
'rscore':rscore,
|
||||
'trimp':trimp,
|
||||
'completedate':completedate,
|
||||
'status':status,
|
||||
'status':status,
|
||||
}
|
||||
|
||||
return thedict
|
||||
@@ -154,7 +154,7 @@ def is_session_complete_ws(ws,ps):
|
||||
return ratio,status,None
|
||||
else:
|
||||
return 0,'not done',None
|
||||
|
||||
|
||||
value = ps.sessionvalue
|
||||
if ps.sessionunit == 'min':
|
||||
value *= 60.
|
||||
@@ -171,7 +171,7 @@ def is_session_complete_ws(ws,ps):
|
||||
cratiomin = 0.9167
|
||||
cratiomax = 1.0833
|
||||
|
||||
|
||||
|
||||
score = 0
|
||||
completiondate = None
|
||||
for w in ws:
|
||||
@@ -236,7 +236,7 @@ def is_session_complete_ws(ws,ps):
|
||||
else:
|
||||
if not completiondate:
|
||||
completiondate = ws.reverse()[0].date
|
||||
return ratio,'partial',completiondate
|
||||
return ratio,'partial',completiondate
|
||||
elif ps.sessiontype == 'coursetest':
|
||||
if ps.course:
|
||||
(
|
||||
@@ -274,19 +274,19 @@ def is_session_complete_ws(ws,ps):
|
||||
if not completiondate:
|
||||
completiondate = ws.reverse()[0].date
|
||||
return ratio,status,completiondate
|
||||
|
||||
|
||||
|
||||
def is_session_complete(r,ps):
|
||||
status = 'not done'
|
||||
|
||||
if r not in ps.rower.all():
|
||||
return 0,'not assigned',None
|
||||
|
||||
|
||||
ws = Workout.objects.filter(user=r,plannedsession=ps)
|
||||
|
||||
return is_session_complete_ws(ws,ps)
|
||||
|
||||
|
||||
|
||||
|
||||
def rank_results(ps):
|
||||
return 1
|
||||
|
||||
@@ -299,7 +299,7 @@ def add_team_session(t,ps):
|
||||
def add_rower_session(r,ps):
|
||||
ps.rower.add(r)
|
||||
ps.save()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
def remove_team_session(t,ps):
|
||||
@@ -364,8 +364,11 @@ def get_sessions_manager(m,teamid=0,startdate=date.today(),
|
||||
enddate=date.today()+timezone.timedelta(+1000)):
|
||||
if teamid:
|
||||
t = Team.objects.get(id=teamid)
|
||||
rs = Rower.objects.filter(
|
||||
team__in=[t]
|
||||
).distinct()
|
||||
sps = PlannedSession.objects.filter(
|
||||
team__in=[t],
|
||||
rower__in=rs,
|
||||
manager=m,
|
||||
startdate__lte=enddate,
|
||||
enddate__gte=startdate,
|
||||
@@ -376,9 +379,9 @@ def get_sessions_manager(m,teamid=0,startdate=date.today(),
|
||||
startdate__lte=enddate,
|
||||
enddate__gte=startdate,
|
||||
).order_by("preferreddate","startdate","enddate")
|
||||
|
||||
|
||||
return sps
|
||||
|
||||
|
||||
def get_sessions(r,startdate=date.today(),
|
||||
enddate=date.today()+timezone.timedelta(+1000)):
|
||||
|
||||
@@ -387,7 +390,7 @@ def get_sessions(r,startdate=date.today(),
|
||||
startdate__lte=enddate,
|
||||
enddate__gte=startdate,
|
||||
).order_by("preferreddate","startdate","enddate")
|
||||
|
||||
|
||||
return sps
|
||||
|
||||
def get_workouts_session(r,ps):
|
||||
|
||||
Reference in New Issue
Block a user