Private
Public Access
1
0

session coach view v1

This commit is contained in:
Sander Roosendaal
2018-02-11 13:55:51 +01:00
parent fdc4ec15ea
commit 8884e2f7b1
7 changed files with 228 additions and 12 deletions

View File

@@ -16,7 +16,7 @@ queuelow = django_rq.get_queue('low')
queuehigh = django_rq.get_queue('low')
from rowers.models import (
Rower, Workout,
Rower, Workout,Team,
GeoCourse, TrainingMicroCycle,TrainingMesoCycle,TrainingMacroCycle,
TrainingPlan,PlannedSession,
)
@@ -118,6 +118,9 @@ def get_session_metrics(ps):
def is_session_complete(r,ps):
status = 'not done'
if r not in ps.rower.all():
return 0,'not assigned'
ws = Workout.objects.filter(user=r,plannedsession=ps)
@@ -253,6 +256,25 @@ def get_dates_timeperiod(timeperiod):
return startdate,enddate
def get_sessions_manager(m,teamid=0,startdate=date.today(),
enddate=date.today()+timezone.timedelta(+1000)):
if teamid:
t = Team.objects.get(id=teamid)
sps = PlannedSession.objects.filter(
team__in=[t],
manager=m,
startdate__lte=enddate,
enddate__gte=startdate,
).order_by("startdate","enddate")
else:
sps = PlannedSession.objects.filter(
manager=m,
startdate__lte=enddate,
enddate__gte=startdate,
).order_by("startdate","enddate")
return sps
def get_sessions(r,startdate=date.today(),
enddate=date.today()+timezone.timedelta(+1000)):
@@ -264,17 +286,6 @@ def get_sessions(r,startdate=date.today(),
return sps
def get_sessions_manager(manager,startdate=date.today(),
enddate=date.today()+timezone.timedelta(+1000)):
sps = PlannedSession.objects.filter(
manager=manager,
startdate__lte=enddate,
enddate__gte=startdate,
).order_by("startdate","enddate").exclude(team__isnull=True)
return sps
def get_workouts_session(r,ps):
ws = Workout.objects.filter(user=r,plannedsession=ps)