Private
Public Access
1
0

Merge branch 'release/v8.31'

This commit is contained in:
Sander Roosendaal
2018-10-29 11:11:37 +01:00
3 changed files with 82 additions and 50 deletions
+12 -13
View File
@@ -247,19 +247,18 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
durations = [] durations = []
for w in workouts: for w in workouts:
if w.privacy == 'visible': dd = w.date.strftime('%m/%d')
dd = w.date.strftime('%m/%d') dd2 = w.date.strftime('%Y/%m/%d')
dd2 = w.date.strftime('%Y/%m/%d') du = w.duration.hour*60+w.duration.minute
du = w.duration.hour*60+w.duration.minute dates.append(dd)
dates.append(dd) dates_sorting.append(dd2)
dates_sorting.append(dd2) durations.append(du)
durations.append(du)
types.append(w.workouttype)
types.append(w.workouttype) try:
try: rowers.append(w.user.user.first_name[0]+w.user.user.last_name[0])
rowers.append(w.user.user.first_name[0]+w.user.user.last_name[0]) except IndexError:
except IndexError: rowers.append(str(w.user))
rowers.append(str(w.user))
try: try:
d = utc.localize(startdate) d = utc.localize(startdate)
+1 -1
View File
@@ -837,7 +837,7 @@ def checkworkoutuser(user,workout):
return True return True
elif teams: elif teams:
for team in teams: for team in teams:
if user == team.manager: if user == team.manager and workout.privacy == 'visible':
return True return True
else: else:
return False return False
+69 -36
View File
@@ -6692,29 +6692,52 @@ def workouts_view(request,message='',successmessage='',
raise Http404("Team doesn't exist") raise Http404("Team doesn't exist")
if theteam.viewing == 'allmembers' or theteam.manager == request.user: if theteam.viewing == 'allmembers' or theteam.manager == request.user:
workouts = Workout.objects.filter(team=theteam, workouts = Workout.objects.filter(
startdatetime__gte=startdate, team=theteam,
startdatetime__lte=enddate).order_by("-date","-starttime") startdatetime__gte=startdate,
g_workouts = Workout.objects.filter(team=theteam, startdatetime__lte=enddate,
startdatetime__gte=activity_startdate, privacy='visible').order_by("-date","-starttime")
startdatetime__lte=activity_enddate).order_by("-date", "-starttime") g_workouts = Workout.objects.filter(
team=theteam,
startdatetime__gte=activity_startdate,
startdatetime__lte=activity_enddate,
privacy='visible').order_by("-date", "-starttime")
elif theteam.viewing == 'coachonly': elif theteam.viewing == 'coachonly':
workouts = Workout.objects.filter(team=theteam,user=r, workouts = Workout.objects.filter(
startdatetime__gte=startdate, team=theteam,user=r,
startdatetime__lte=enddate).order_by("-startdatetime") startdatetime__gte=startdate,
g_workouts = Workout.objects.filter(team=theteam,user=r, startdatetime__lte=enddate,
startdatetime__gte=activity_startdate, privacy='visible').order_by("-startdatetime")
enddatetime__lte=activity_enddate).order_by("-startdatetime") g_workouts = Workout.objects.filter(
team=theteam,user=r,
startdatetime__gte=activity_startdate,
enddatetime__lte=activity_enddate,
privacy='visible').order_by("-startdatetime")
else: elif request.user != r.user:
theteam = None theteam = None
workouts = Workout.objects.filter(user=r, workouts = Workout.objects.filter(
startdatetime__gte=startdate, user=r,
startdatetime__lte=enddate).order_by("-date", "-starttime") startdatetime__gte=startdate,
g_workouts = Workout.objects.filter(user=r, startdatetime__lte=enddate,
startdatetime__gte=activity_startdate, privacy='visible').order_by("-date", "-starttime")
startdatetime__lte=activity_enddate).order_by("-startdatetime") g_workouts = Workout.objects.filter(
user=r,
startdatetime__gte=activity_startdate,
startdatetime__lte=activity_enddate,
privacy='visible').order_by("-startdatetime")
else:
theteam = None
workouts = Workout.objects.filter(
user=r,
startdatetime__gte=startdate,
startdatetime__lte=enddate).order_by("-date", "-starttime")
g_workouts = Workout.objects.filter(
user=r,
startdatetime__gte=activity_startdate,
startdatetime__lte=activity_enddate).order_by("-startdatetime")
if rankingonly: if rankingonly:
workouts = [w for w in workouts if w.rankingpiece] workouts = [w for w in workouts if w.rankingpiece]
@@ -7036,7 +7059,7 @@ def workout_view(request,id=0):
}, },
{ {
'url':reverse(workout_view,kwargs={'id':id}), 'url':reverse(workout_view,kwargs={'id':id}),
'name': id, 'name': row.name,
} }
] ]
@@ -14623,14 +14646,6 @@ def plannedsessions_view(request,
r = getrequestrower(request,userid=userid) r = getrequestrower(request,userid=userid)
when = request.GET.get('when')
if when:
timeperiod = when
else:
timeperiod = 'thisweek'
startdate,enddate = get_dates_timeperiod(timeperiod)
if startdatestring: if startdatestring:
try: try:
startdate = iso8601.parse_date(startdatestring) startdate = iso8601.parse_date(startdatestring)
@@ -14643,6 +14658,21 @@ def plannedsessions_view(request,
except ParseError: except ParseError:
pass pass
when = request.GET.get('when')
if when:
timeperiod = when
startdate,enddate = get_dates_timeperiod(timeperiod)
else:
timeperiod = 'thisweek'
startdate1,enddate1 = get_dates_timeperiod(timeperiod)
if not startdatestring:
startdate = startdate1
if not enddatestring:
enddate = enddate1
try: try:
trainingplan = TrainingPlan.objects.filter( trainingplan = TrainingPlan.objects.filter(
startdate__lte = startdate, startdate__lte = startdate,
@@ -16982,7 +17012,7 @@ class TrainingTargetUpdate(UpdateView):
def allsundays(startdate,enddate): def allsundays(startdate,enddate):
d = startdate d = startdate
d += timedelta(days = 6 - d.weekday()) # first Sunday d += timedelta(days = 6 - d.weekday()) # first Sunday
while d<enddate: while d<=enddate:
yield d yield d
d += timedelta(days=7) d += timedelta(days=7)
@@ -16990,6 +17020,7 @@ def allsundays(startdate,enddate):
message="This functionality requires a Coach or Self-Coach plan", message="This functionality requires a Coach or Self-Coach plan",
redirect_field_name=None) redirect_field_name=None)
def planmesocyclebyweek(request,id=0,userid=0): def planmesocyclebyweek(request,id=0,userid=0):
print 'planning by week'
try: try:
cycle = TrainingMesoCycle.objects.get(id=id) cycle = TrainingMesoCycle.objects.get(id=id)
except TrainingMesoCycle.DoesNotExist: except TrainingMesoCycle.DoesNotExist:
@@ -17007,17 +17038,19 @@ def planmesocyclebyweek(request,id=0,userid=0):
#we're still here. We have permission #we're still here. We have permission
sundays = [s for s in allsundays(cycle.startdate,cycle.enddate)] sundays = [s for s in allsundays(cycle.startdate,cycle.enddate)]
for i in range(len(sundays)-1): for i in range(len(sundays)):
monday = sundays[i]+timedelta(days=1) if i==0:
nextsunday = sundays[i+1]
if i == 0 and monday > cycle.startdate:
monday = cycle.startdate monday = cycle.startdate
if nextsunday < cycle.enddate and i == len(sundays)-2: else:
nextsunday = cycle.enddate monday = sundays[i]-timedelta(days=6)
if monday < cycle.startdate:
monday = cycle.startdate
nextsunday = sundays[i]
micro = TrainingMicroCycle(startdate = monday, micro = TrainingMicroCycle(startdate = monday,
enddate = nextsunday, enddate = nextsunday,
plan = cycle, plan = cycle,
name = 'Week %s' % sundays[i+1].isocalendar()[1], name = 'Week %s' % monday.isocalendar()[1],
type = 'userdefined') type = 'userdefined')
micro.save() micro.save()