Merge branch 'feature/speed' into develop
This commit is contained in:
+3
-3
@@ -104,7 +104,7 @@ def alert_get_stats(alert,nperiod=0):
|
|||||||
|
|
||||||
if df.empty:
|
if df.empty:
|
||||||
return {
|
return {
|
||||||
'workouts':len(workouts),
|
'workouts':workouts.count(),
|
||||||
'startdate':startdate,
|
'startdate':startdate,
|
||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
'nr_strokes':0,
|
'nr_strokes':0,
|
||||||
@@ -139,7 +139,7 @@ def alert_get_stats(alert,nperiod=0):
|
|||||||
df.dropna(inplace=True,axis=0)
|
df.dropna(inplace=True,axis=0)
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
'workouts':len(workouts),
|
'workouts':workouts.count(),
|
||||||
'startdate':startdate,
|
'startdate':startdate,
|
||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
'nr_strokes':0,
|
'nr_strokes':0,
|
||||||
@@ -183,7 +183,7 @@ def alert_get_stats(alert,nperiod=0):
|
|||||||
std = df[alert.measured.metric].std()
|
std = df[alert.measured.metric].std()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'workouts':len(workouts),
|
'workouts':workouts.count(),
|
||||||
'startdate':startdate,
|
'startdate':startdate,
|
||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
'nr_strokes':nr_strokes,
|
'nr_strokes':nr_strokes,
|
||||||
|
|||||||
+4
-4
@@ -364,7 +364,7 @@ class Team(models.Model):
|
|||||||
|
|
||||||
if manager.rower.rowerplan in ['plan','pro']:
|
if manager.rower.rowerplan in ['plan','pro']:
|
||||||
otherteams = Team.objects.filter(manager=manager)
|
otherteams = Team.objects.filter(manager=manager)
|
||||||
if len(otherteams) >= 1:
|
if otherteams.count() >= 1:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
"Pro and Self-Coach users cannot have more than one team"
|
"Pro and Self-Coach users cannot have more than one team"
|
||||||
)
|
)
|
||||||
@@ -569,7 +569,7 @@ def course_length(course):
|
|||||||
if not polygons:
|
if not polygons:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
for i in range(len(polygons)-1):
|
for i in range(polygons.count()-1):
|
||||||
latitude1,longitude1 = polygon_coord_center(polygons[i])
|
latitude1,longitude1 = polygon_coord_center(polygons[i])
|
||||||
latitude2,longitude2 = polygon_coord_center(polygons[i+1])
|
latitude2,longitude2 = polygon_coord_center(polygons[i+1])
|
||||||
|
|
||||||
@@ -656,7 +656,7 @@ class CoachingGroup(models.Model):
|
|||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
rs = Rower.objects.filter(coachinggroups__in=[self])
|
rs = Rower.objects.filter(coachinggroups__in=[self])
|
||||||
return len(rs)
|
return rs.count()
|
||||||
|
|
||||||
# Extension of User with rowing specific data
|
# Extension of User with rowing specific data
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
@@ -3133,7 +3133,7 @@ def auto_delete_image_on_delete(sender,instance, **kwargs):
|
|||||||
if instance.filename:
|
if instance.filename:
|
||||||
if os.path.isfile(instance.filename):
|
if os.path.isfile(instance.filename):
|
||||||
others = GraphImage.objects.filter(filename=instance.filename)
|
others = GraphImage.objects.filter(filename=instance.filename)
|
||||||
if len(others) == 0:
|
if others.count() == 0:
|
||||||
os.remove(instance.filename)
|
os.remove(instance.filename)
|
||||||
else:
|
else:
|
||||||
print("couldn't find the file "+instance.filename)
|
print("couldn't find the file "+instance.filename)
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ def get_session_metrics(ps):
|
|||||||
|
|
||||||
ws = Workout.objects.filter(user=r,plannedsession=ps).order_by("date")
|
ws = Workout.objects.filter(user=r,plannedsession=ps).order_by("date")
|
||||||
|
|
||||||
if len(ws) != 0:
|
if ws.count() != 0:
|
||||||
for w in ws:
|
for w in ws:
|
||||||
distancev += w.distance
|
distancev += w.distance
|
||||||
durationv += timefield_to_seconds_duration(w.duration)
|
durationv += timefield_to_seconds_duration(w.duration)
|
||||||
@@ -493,7 +493,7 @@ cratiocolors = {
|
|||||||
|
|
||||||
def is_session_complete_ws(ws,ps):
|
def is_session_complete_ws(ws,ps):
|
||||||
ws = ws.order_by("date")
|
ws = ws.order_by("date")
|
||||||
if len(ws)==0:
|
if ws.count()==0:
|
||||||
today = date.today()
|
today = date.today()
|
||||||
if today > ps.enddate:
|
if today > ps.enddate:
|
||||||
verdict = 'missed'
|
verdict = 'missed'
|
||||||
@@ -1330,7 +1330,7 @@ def add_workout_indoorrace(ws,race,r,recordid=0):
|
|||||||
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
|
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
|
||||||
return result,comments,errors,0
|
return result,comments,errors,0
|
||||||
|
|
||||||
if len(ws)>1 and race.sessiontype == 'test':
|
if ws.count()>1 and race.sessiontype == 'test':
|
||||||
errors.append('For tests, you can only attach one workout')
|
errors.append('For tests, you can only attach one workout')
|
||||||
return result,comments,errors,0
|
return result,comments,errors,0
|
||||||
|
|
||||||
@@ -1458,7 +1458,7 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
|
|||||||
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
|
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
|
||||||
return result,comments,errors,0
|
return result,comments,errors,0
|
||||||
|
|
||||||
if len(ws)>1 and race.sessiontype == 'test':
|
if ws.count()>1 and race.sessiontype == 'test':
|
||||||
errors.append('For tests, you can only attach one workout')
|
errors.append('For tests, you can only attach one workout')
|
||||||
return result,comments,errors,0
|
return result,comments,errors,0
|
||||||
|
|
||||||
@@ -1549,5 +1549,3 @@ def delete_race_result(workout,race):
|
|||||||
for r in results:
|
for r in results:
|
||||||
r.workoutid = None
|
r.workoutid = None
|
||||||
r.save()
|
r.save()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ def plannedsession_multiclone_view(
|
|||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(Team.objects.filter(manager=request.user))>=1:
|
if Team.objects.filter(manager=request.user).count()>=1:
|
||||||
teamform = RowerTeamForm(request.user)
|
teamform = RowerTeamForm(request.user)
|
||||||
if teamid:
|
if teamid:
|
||||||
teamform = RowerTeamForm(request.user,initial={'team':teamid})
|
teamform = RowerTeamForm(request.user,initial={'team':teamid})
|
||||||
@@ -587,7 +587,7 @@ def plannedsession_multicreate_view(request,
|
|||||||
'enddate':enddate
|
'enddate':enddate
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(Team.objects.filter(manager=request.user))>=1:
|
if Team.objects.filter(manager=request.user).count()>=1:
|
||||||
teamform = RowerTeamForm(request.user)
|
teamform = RowerTeamForm(request.user)
|
||||||
if teamid:
|
if teamid:
|
||||||
teamform = RowerTeamForm(request.user,initial={'team':teamid})
|
teamform = RowerTeamForm(request.user,initial={'team':teamid})
|
||||||
@@ -623,7 +623,7 @@ def plannedsession_teamcreate_view(request,
|
|||||||
|
|
||||||
|
|
||||||
teams = Team.objects.filter(manager=request.user)
|
teams = Team.objects.filter(manager=request.user)
|
||||||
if len(teams)>0:
|
if teams.count()>0:
|
||||||
teamchoices = [(team.id, team.name) for team in teams]
|
teamchoices = [(team.id, team.name) for team in teams]
|
||||||
teaminitial = [str(teams[0].id)]
|
teaminitial = [str(teams[0].id)]
|
||||||
else:
|
else:
|
||||||
@@ -1320,7 +1320,7 @@ def plannedsessions_manage_view(request,userid=0,
|
|||||||
else:
|
else:
|
||||||
selectedworkouts = []
|
selectedworkouts = []
|
||||||
|
|
||||||
if len(selectedworkouts)==0:
|
if selectedworkouts.count()==0:
|
||||||
for w in ws:
|
for w in ws:
|
||||||
remove_workout_plannedsession(w,ps)
|
remove_workout_plannedsession(w,ps)
|
||||||
|
|
||||||
@@ -1476,7 +1476,7 @@ def plannedsession_teamclone_view(request,id=0):
|
|||||||
r = getrequestplanrower(request)
|
r = getrequestplanrower(request)
|
||||||
|
|
||||||
teams = Team.objects.filter(manager=request.user)
|
teams = Team.objects.filter(manager=request.user)
|
||||||
if len(teams)>0:
|
if teams.count()>0:
|
||||||
teamchoices = [(team.id, team.name) for team in teams]
|
teamchoices = [(team.id, team.name) for team in teams]
|
||||||
teaminitial = [str(teams[0].id)]
|
teaminitial = [str(teams[0].id)]
|
||||||
else:
|
else:
|
||||||
@@ -1596,7 +1596,7 @@ def plannedsession_edit_view(request,id=0,userid=0):
|
|||||||
if ps.sessiontype in ['race','indoorrace']:
|
if ps.sessiontype in ['race','indoorrace']:
|
||||||
raise PermissionDenied("You are not allowed to edit this planned session because it is a race")
|
raise PermissionDenied("You are not allowed to edit this planned session because it is a race")
|
||||||
|
|
||||||
if ps.team.all() or len(ps.rower.all())>1:
|
if ps.team.all() or ps.rower.all().count()>1:
|
||||||
url = reverse(plannedsession_teamedit_view,
|
url = reverse(plannedsession_teamedit_view,
|
||||||
kwargs={
|
kwargs={
|
||||||
'sessionid':id,
|
'sessionid':id,
|
||||||
@@ -2941,6 +2941,3 @@ def planmacrocyclebymonth(request,id=0,userid=0):
|
|||||||
'thismesoid':str(mesos[0].id)})
|
'thismesoid':str(mesos[0].id)})
|
||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2358,7 +2358,7 @@ def instroke_chart(request,id=0,metric=''):
|
|||||||
height = 600
|
height = 600
|
||||||
|
|
||||||
imgs = GraphImage.objects.filter(workout=w)
|
imgs = GraphImage.objects.filter(workout=w)
|
||||||
if len(imgs) < 7:
|
if imgs.count() < 7:
|
||||||
i = GraphImage(workout=w,
|
i = GraphImage(workout=w,
|
||||||
creationdatetime=timezone.now(),
|
creationdatetime=timezone.now(),
|
||||||
filename=fullpathimagename,
|
filename=fullpathimagename,
|
||||||
@@ -3451,7 +3451,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
except UnknownTimeZoneError:
|
except UnknownTimeZoneError:
|
||||||
thetimezone = 'UTC'
|
thetimezone = 'UTC'
|
||||||
|
|
||||||
|
timechanged = (startdatetime != row.startdatetime)
|
||||||
|
|
||||||
row.name = name
|
row.name = name
|
||||||
row.date = date
|
row.date = date
|
||||||
@@ -3484,35 +3484,29 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
add_workouts_plannedsession([row],ps,row.user)
|
add_workouts_plannedsession([row],ps,row.user)
|
||||||
|
|
||||||
# change data in csv file
|
# change data in csv file
|
||||||
|
datachanged = (dragchanged or timechanged)
|
||||||
|
if datachanged:
|
||||||
|
r = rdata(row.csvfilename)
|
||||||
|
if dragchanged:
|
||||||
|
try:
|
||||||
|
r.change_drag(newdragfactor)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
r = rdata(row.csvfilename)
|
if r == 0:
|
||||||
if dragchanged:
|
return HttpResponse("Error: CSV Data File Not Found")
|
||||||
try:
|
r.rowdatetime = startdatetime
|
||||||
r.change_drag(newdragfactor)
|
r.write_csv(row.csvfilename,gzip=True)
|
||||||
except AttributeError:
|
dataprep.update_strokedata(encoder.decode_hex(id),r.df)
|
||||||
pass
|
|
||||||
|
|
||||||
if r == 0:
|
|
||||||
return HttpResponse("Error: CSV Data File Not Found")
|
|
||||||
r.rowdatetime = startdatetime
|
|
||||||
r.write_csv(row.csvfilename,gzip=True)
|
|
||||||
dataprep.update_strokedata(encoder.decode_hex(id),r.df)
|
|
||||||
successmessage = "Changes saved"
|
successmessage = "Changes saved"
|
||||||
|
|
||||||
if rankingpiece:
|
if rankingpiece:
|
||||||
dataprep.runcpupdate(row.user,type=row.workouttype)
|
dataprep.runcpupdate(row.user,type=row.workouttype)
|
||||||
|
|
||||||
messages.info(request,successmessage)
|
messages.info(request,successmessage)
|
||||||
url = reverse('workout_edit_view',
|
else:
|
||||||
kwargs = {
|
form = WorkoutForm(instance=row)
|
||||||
'id':encoder.encode_hex(row.id),
|
|
||||||
})
|
|
||||||
response = HttpResponseRedirect(url)
|
|
||||||
|
|
||||||
#else: # form not POSTed
|
|
||||||
form = WorkoutForm(instance=row)
|
|
||||||
|
|
||||||
row = get_workout(id)
|
|
||||||
|
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
for i in g:
|
for i in g:
|
||||||
@@ -3704,7 +3698,7 @@ def workout_uploadimage_view(request,id):
|
|||||||
images = GraphImage.objects.filter(workout=w)
|
images = GraphImage.objects.filter(workout=w)
|
||||||
|
|
||||||
|
|
||||||
if len(images) >= 6:
|
if images.count() >= 6:
|
||||||
message = "You have reached the maximum number of static images for this workout"
|
message = "You have reached the maximum number of static images for this workout"
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
url = reverse(r.defaultlandingpage,
|
url = reverse(r.defaultlandingpage,
|
||||||
|
|||||||
Reference in New Issue
Block a user