Private
Public Access
1
0

Merge branch 'feature/speed' into develop

This commit is contained in:
Sander Roosendaal
2019-10-31 21:03:22 +01:00
5 changed files with 265 additions and 276 deletions
+3 -3
View File
@@ -104,7 +104,7 @@ def alert_get_stats(alert,nperiod=0):
if df.empty:
return {
'workouts':len(workouts),
'workouts':workouts.count(),
'startdate':startdate,
'enddate':enddate,
'nr_strokes':0,
@@ -139,7 +139,7 @@ def alert_get_stats(alert,nperiod=0):
df.dropna(inplace=True,axis=0)
else:
return {
'workouts':len(workouts),
'workouts':workouts.count(),
'startdate':startdate,
'enddate':enddate,
'nr_strokes':0,
@@ -183,7 +183,7 @@ def alert_get_stats(alert,nperiod=0):
std = df[alert.measured.metric].std()
return {
'workouts':len(workouts),
'workouts':workouts.count(),
'startdate':startdate,
'enddate':enddate,
'nr_strokes':nr_strokes,
+4 -4
View File
@@ -364,7 +364,7 @@ class Team(models.Model):
if manager.rower.rowerplan in ['plan','pro']:
otherteams = Team.objects.filter(manager=manager)
if len(otherteams) >= 1:
if otherteams.count() >= 1:
raise ValidationError(
"Pro and Self-Coach users cannot have more than one team"
)
@@ -569,7 +569,7 @@ def course_length(course):
if not polygons:
return 0
for i in range(len(polygons)-1):
for i in range(polygons.count()-1):
latitude1,longitude1 = polygon_coord_center(polygons[i])
latitude2,longitude2 = polygon_coord_center(polygons[i+1])
@@ -656,7 +656,7 @@ class CoachingGroup(models.Model):
def __len__(self):
rs = Rower.objects.filter(coachinggroups__in=[self])
return len(rs)
return rs.count()
# Extension of User with rowing specific data
@python_2_unicode_compatible
@@ -3133,7 +3133,7 @@ def auto_delete_image_on_delete(sender,instance, **kwargs):
if instance.filename:
if os.path.isfile(instance.filename):
others = GraphImage.objects.filter(filename=instance.filename)
if len(others) == 0:
if others.count() == 0:
os.remove(instance.filename)
else:
print("couldn't find the file "+instance.filename)
+4 -6
View File
@@ -438,7 +438,7 @@ def get_session_metrics(ps):
ws = Workout.objects.filter(user=r,plannedsession=ps).order_by("date")
if len(ws) != 0:
if ws.count() != 0:
for w in ws:
distancev += w.distance
durationv += timefield_to_seconds_duration(w.duration)
@@ -493,7 +493,7 @@ cratiocolors = {
def is_session_complete_ws(ws,ps):
ws = ws.order_by("date")
if len(ws)==0:
if ws.count()==0:
today = date.today()
if today > ps.enddate:
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')
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')
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')
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')
return result,comments,errors,0
@@ -1549,5 +1549,3 @@ def delete_race_result(workout,race):
for r in results:
r.workoutid = None
r.save()
+6 -9
View File
@@ -297,7 +297,7 @@ def plannedsession_multiclone_view(
'enddate':enddate,
})
if len(Team.objects.filter(manager=request.user))>=1:
if Team.objects.filter(manager=request.user).count()>=1:
teamform = RowerTeamForm(request.user)
if teamid:
teamform = RowerTeamForm(request.user,initial={'team':teamid})
@@ -587,7 +587,7 @@ def plannedsession_multicreate_view(request,
'enddate':enddate
})
if len(Team.objects.filter(manager=request.user))>=1:
if Team.objects.filter(manager=request.user).count()>=1:
teamform = RowerTeamForm(request.user)
if teamid:
teamform = RowerTeamForm(request.user,initial={'team':teamid})
@@ -623,7 +623,7 @@ def plannedsession_teamcreate_view(request,
teams = Team.objects.filter(manager=request.user)
if len(teams)>0:
if teams.count()>0:
teamchoices = [(team.id, team.name) for team in teams]
teaminitial = [str(teams[0].id)]
else:
@@ -1320,7 +1320,7 @@ def plannedsessions_manage_view(request,userid=0,
else:
selectedworkouts = []
if len(selectedworkouts)==0:
if selectedworkouts.count()==0:
for w in ws:
remove_workout_plannedsession(w,ps)
@@ -1476,7 +1476,7 @@ def plannedsession_teamclone_view(request,id=0):
r = getrequestplanrower(request)
teams = Team.objects.filter(manager=request.user)
if len(teams)>0:
if teams.count()>0:
teamchoices = [(team.id, team.name) for team in teams]
teaminitial = [str(teams[0].id)]
else:
@@ -1596,7 +1596,7 @@ def plannedsession_edit_view(request,id=0,userid=0):
if ps.sessiontype in ['race','indoorrace']:
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,
kwargs={
'sessionid':id,
@@ -2941,6 +2941,3 @@ def planmacrocyclebymonth(request,id=0,userid=0):
'thismesoid':str(mesos[0].id)})
return HttpResponseRedirect(url)
+7 -13
View File
@@ -2358,7 +2358,7 @@ def instroke_chart(request,id=0,metric=''):
height = 600
imgs = GraphImage.objects.filter(workout=w)
if len(imgs) < 7:
if imgs.count() < 7:
i = GraphImage(workout=w,
creationdatetime=timezone.now(),
filename=fullpathimagename,
@@ -3451,7 +3451,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
except UnknownTimeZoneError:
thetimezone = 'UTC'
timechanged = (startdatetime != row.startdatetime)
row.name = name
row.date = date
@@ -3484,7 +3484,8 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
add_workouts_plannedsession([row],ps,row.user)
# change data in csv file
datachanged = (dragchanged or timechanged)
if datachanged:
r = rdata(row.csvfilename)
if dragchanged:
try:
@@ -3497,23 +3498,16 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
r.rowdatetime = startdatetime
r.write_csv(row.csvfilename,gzip=True)
dataprep.update_strokedata(encoder.decode_hex(id),r.df)
successmessage = "Changes saved"
if rankingpiece:
dataprep.runcpupdate(row.user,type=row.workouttype)
messages.info(request,successmessage)
url = reverse('workout_edit_view',
kwargs = {
'id':encoder.encode_hex(row.id),
})
response = HttpResponseRedirect(url)
#else: # form not POSTed
else:
form = WorkoutForm(instance=row)
row = get_workout(id)
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
for i in g:
try:
@@ -3704,7 +3698,7 @@ def workout_uploadimage_view(request,id):
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"
messages.error(request,message)
url = reverse(r.defaultlandingpage,