Private
Public Access
1
0

Merge branch 'release/v8.48'

This commit is contained in:
Sander Roosendaal
2018-11-13 15:21:29 +01:00
15 changed files with 169 additions and 75 deletions
+43 -17
View File
@@ -219,14 +219,25 @@ def get_session_metrics(ps):
return thedict
cratiocolors = {
'better than nothing': "lightgreen",
'partial': "mediumgreen",
'on target': "green",
'over target': "purple",
'way over target': "violet",
'missed': "black",
'not assigned': "",
'not done': "white",
}
def is_session_complete_ws(ws,ps):
ws = ws.order_by("date")
if len(ws)==0:
today = date.today()
if today > ps.enddate:
status = 'missed'
verdict = 'missed'
ratio = 0
return ratio,status,None
return ratio,verdict,None
else:
return 0,'not done',None
@@ -238,11 +249,23 @@ def is_session_complete_ws(ws,ps):
cratiomin = 1
cratiomax = 1
cratios = {
'better than nothing':0,
'partial':0.6,
'on target':0.8,
'over target':1.2,
'way over target': 1.5
}
if ps.criterium == 'none':
if ps.sessiontype == 'session':
cratiomin = 0.8
cratiomax = 1.2
else:
cratios['on target'] = 0.9167
cratios['over target'] = 1.0833
cratiomin = 0.9167
cratiomax = 1.0833
@@ -271,44 +294,47 @@ def is_session_complete_ws(ws,ps):
ratio = score/float(value)
status = 'partial'
verdict = 'better than nothing'
if ps.sessiontype in ['session','cycletarget']:
if ps.criterium == 'exact':
if ratio == 1.0:
return ratio,'completed',completiondate
return ratio,'on target',completiondate
else:
if not completiondate:
completiondate = ws.reverse()[0].date
return ratio,'partial',completiondate
elif ps.criterium == 'minimum':
if ratio >= 1.0:
return ratio,'completed',completiondate
return ratio,'on target',completiondate
else:
if not completiondate:
completiondate = ws.reverse()[0].date
return ratio,'partial',completiondate
else:
if ratio>cratiomin and ratio<cratiomax:
return ratio,'completed',completiondate
else:
completiondate = ws.reverse()[0].date
return ratio,'partial',completiondate
thevalue = 0
for key,value in cratios.iteritems():
if ratio>value and value>thevalue:
verdict = key
thevalue = value
completiondate = ws.reverse()[0].date
return ratio,verdict,completiondate
elif ps.sessiontype == 'test':
if ratio==1.0:
return ratio,'completed',completiondate
return ratio,'on target',completiondate
else:
return ratio,'partial',completiondate
elif ps.sessiontype == 'challenge':
if ps.criterium == 'exact':
if ratio == 1.0:
return ratio,'completed',completiondate
return ratio,'on target',completiondate
else:
return ratio,'partial',completiondate
elif ps.criterium == 'minimum':
if ratio > 1.0:
return ratio,'completed',completiondate
return ratio,'on target',completiondate
else:
if not completiondate:
completiondate = ws.reverse()[0].date
@@ -324,7 +350,7 @@ def is_session_complete_ws(ws,ps):
if record.workoutid in wids:
if record.coursecompleted:
ratio = record.distance/ps.sessionvalue
return ratio,'completed',completiondate
return ratio,'on target',completiondate
else:
ratio = record.distance/ps.sessionvalue
return ratio,'partial',completiondate
@@ -336,7 +362,7 @@ def is_session_complete_ws(ws,ps):
if record.workoutid in wids:
if record.coursecompleted:
ratio = record.distance/float(ps.sessionvalue)
return ratio,'completed',completiondate
return ratio,'on target',completiondate
else:
ratio = record.distance/float(ps.sessionvalue)
return ratio,'partial',completiondate
@@ -361,11 +387,11 @@ def is_session_complete_ws(ws,ps):
else:
if not completiondate:
completiondate = ws.reverse()[0].date
return ratio,status,completiondate
return ratio,verdict,completiondate
def is_session_complete(r,ps):
status = 'not done'
verdict = 'not done'
if r not in ps.rower.all():
+14 -2
View File
@@ -248,7 +248,7 @@ def get_workout(user,stravaid):
velojson = get_strava_stream(r,'velocity_smooth',stravaid)
distancejson = get_strava_stream(r,'distance',stravaid)
latlongjson = get_strava_stream(r,'latlng',stravaid)
powerjson = get_strava_stream(r,'power',stravaid)
try:
@@ -269,6 +269,11 @@ def get_workout(user,stravaid):
except:
spm = np.zeros(nr_rows)
try:
power = np.array(powerjson.json()[1]['data'])
except IndexError:
power = np.zeros(nr_rows)
try:
hr = np.array(hrjson.json()[1]['data'])
except IndexError:
@@ -315,6 +320,7 @@ def get_workout(user,stravaid):
'hr':hr,
'lat':lat,
'lon':lon,
'power':power,
'strokelength':strokelength,
})
@@ -494,7 +500,13 @@ def add_workout_from_data(user,importid,data,strokedata,
velo = 500./pace
power = 2.8*velo**3
try:
power = strokedata.ix[:,'power']
except KeyError:
power = 2.8*velo**3
#if power.std() == 0 and power.mean() == 0:
# power = 2.8*velo**3
# save csv
# Create data frame with all necessary data to write to csv
+7 -26
View File
@@ -46,35 +46,16 @@
{% for ps in plannedsessions %}
<tr>
<td>
{% if completeness|lookup:ps.id == 'not done' %}
{% if ps.sessiontype != 'race' %}
<a class="white dot"
<a class="{{ sessioncolor|lookup:ps.id }} dot"
title="{{ completeness|lookup:ps.id }}"
href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}/?when={{ timeperiod }}">
&nbsp;</a>
{% else %}
<a class="white dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
{% elif completeness|lookup:ps.id == 'completed' %}
{% if ps.sessiontype != 'race' %}
<a class="green dot"
href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}/?when={{ timeperiod }}">&nbsp;</a>
{% else %}
<a class="green dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
{% elif completeness|lookup:ps.id == 'partial' %}
{% if ps.sessiontype != 'race' %}
<a class="orange dot"
href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}?when={{ timeperiod }}">&nbsp;</a>
{% else %}
<a class="orange dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
{% else %}
{% if ps.sessiontype != 'race' %}
<a class="red dot"
href="/rowers/sessions/manage/session/{{ ps.id }}/user/{{ rower.user.id }}?when={{ timeperiod }}">&nbsp;</a>
{% else %}
<a class="red dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
<a
class="{{ sessioncolor|lookup:ps.id }} dot"
title="{{ completeness|lookup:ps.id }}"
href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
</td>
<td> {{ ps.startdate|date:"Y-m-d" }} </td>
@@ -111,7 +92,7 @@
<td> {{ ps.sessionvalue }} </td>
<td> {{ actualvalue|lookup:ps.id }}</td>
<td> {{ ps.sessionunit }} </td>
{% if completeness|lookup:ps.id == 'partial' %}
{% if completeness|lookup:ps.id != 'on target' %}
<td style="color:darkgray"><em> {{ completiondate|lookup:ps.id|date:"Y-m-d" }}</em></td>
{% else %}
<td> {{ completiondate|lookup:ps.id|date:"Y-m-d" }}</td>
+4 -12
View File
@@ -58,20 +58,12 @@
</td>
{% for r in rowers %}
<td>
{% if thedict|lookup:'results'|lookup:r.id == 'completed' %}
<a class="green dot"
{% if thedict|lookup:'results'|lookup:r.id != 'not assigned' %}
<a class="{{ thedict|lookup:'color'|lookup:r.id }} dot"
title="{{ thedict|lookup:'results'|lookup:r.id }}"
href="{% url 'plannedsession_view' id=thedict|lookup:"id" userid=r.user.id %}">&nbsp;</a>
{% elif thedict|lookup:'results'|lookup:r.id == 'partial' %}
<a class="orange dot"
href="{% url 'plannedsession_view' id=thedict|lookup:"id" userid=r.user.id %}">&nbsp;</a>
{% elif thedict|lookup:'results'|lookup:r.id == 'not done' %}
<a class="white dot"
href="/rowers/sessions/manage/session/{{ thedict|lookup:"id" }}/user/{{ r.user.id }}/?when={{ timeperiod }}">&nbsp;</a>
{% elif thedict|lookup:'results'|lookup:r.id == 'not assigned' %}
&nbsp;
{% else %}
<a class="red dot"
href="/rowers/sessions/manage/session/{{ thedict|lookup:"id" }}/user/{{ r.user.id }}/?when={{ timeperiod }}">&nbsp;</a>
&nbsp;
{% endif %}
</td>
{% endfor %}
+10 -2
View File
@@ -25,8 +25,16 @@
</li>
<li class="grid_2">
<ul>
<li>Team Type: A private team is invisible on the Teams Management page, except for its members. The only way to add members is for the manager to send an invitation. An open team is visible for all rowsandall.com users. In addition to the invitation mechanism, any user can request to be added to this team. The team manager will always have to approve membership.</li>
<li>Sharing Behavior: When set to "All Members", all members of a team will see each other's workouts. This is the recommended setting. If te sharing bhavior is set to "Coach Only", team members only see their own workouts. The coach sees all team members' workouts.</li>
<li>Team Type: A private team is invisible on the Teams Management page,
except for its members. The only way to add members is for the manager
to send an invitation. An open team is visible for all rowsandall.com users.
In addition to the invitation mechanism, any user can request to be added to
this team. The team manager will always have to approve membership.</li>
<li>Sharing Behavior: When set to "All Members", all members of a team will
see each other's workouts and planned sessions. This is the recommended
setting. If te sharing behavior is set to "Coach Only", team members
only see their own workouts and planned sessions.
The coach sees all team members' workouts.</li>
<li>These settings can be changed at any point in time through the Team Edit page
</li>
</ul>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
[{"data": [0, 0, 0, 0, 0, 0, 0, 0, 51, 53, 54, 56, 58, 60, 63, 65, 67, 69, 71, 73, 76, 78, 80, 82, 85, 87, 89, 91, 94, 96, 98, 100, 102, 105, 107, 109, 111, 113, 116, 118, 120, 122, 125, 127, 129, 131, 133, 136, 138, 140, 142, 145, 147, 149, 152, 154, 156, 158, 161, 163, 165, 167, 170, 172, 174, 176, 179, 181, 183, 185, 188, 190, 192, 194, 197, 199, 201, 203, 206, 208, 210, 212, 215, 217, 219, 221, 224, 226, 228, 231, 233, 235, 238, 240, 242, 244, 247, 249, 251, 253, 256, 258, 260, 263, 265, 267, 270, 272, 274, 277, 279, 281, 283, 286, 288, 290, 293, 295, 297, 299, 301, 304, 306, 308, 310, 313, 315, 317, 319, 322, 324, 326, 328, 331, 333, 335, 337, 339, 342, 344, 346, 349, 351, 353, 355, 357, 360, 362, 364, 367, 369, 371, 374, 376, 378, 380, 383, 385, 387, 389, 391, 394, 396, 398, 400, 403, 405, 407, 409, 411, 414, 416, 418, 420, 423, 425, 427, 429, 432, 434, 436, 438, 441, 443, 445, 447, 450, 452, 454, 456, 458, 461, 463, 465, 467, 469, 472, 474, 476, 478, 481, 483, 485, 487, 489, 491, 494, 496, 498, 500, 503, 505, 507, 509, 512, 514, 516, 518, 521, 523, 525, 527, 529, 532, 534, 536, 538, 541, 543, 545, 547, 549, 552, 554, 556, 558, 561, 563, 565, 567, 569, 572, 574, 576, 578, 581, 583, 585, 587, 589, 592, 594, 596, 598, 601, 603, 605, 607, 609, 611, 614, 616, 618, 620, 623, 625, 627, 629, 632, 634, 636, 638, 640, 643, 645, 647, 650, 652, 654, 656, 658, 661, 663, 665, 667, 669, 672, 674, 676, 678, 681, 683, 685, 687, 690, 692, 694, 696, 699, 701, 703, 705, 708, 710, 712, 714, 716, 719, 721, 723, 726, 728, 730, 733, 735, 737, 740, 742, 744, 747, 749, 751, 753, 756, 758, 760, 763, 765, 767, 769, 772, 774, 776, 779, 781, 783, 785, 788, 790, 792, 794, 796, 799, 801, 803, 805, 808, 810, 812, 814, 817, 819, 821, 823, 825, 828, 830, 832, 834, 837, 839, 841, 843, 845, 848, 850, 852, 854, 856, 858, 861, 863, 865, 867, 869, 872, 874, 876, 878, 881, 883, 885, 887, 890, 892, 894, 896, 898, 901, 903, 905, 907, 910, 912, 914, 916, 919, 921, 923, 925, 927, 930, 932, 934, 936, 939, 941, 943, 945, 948, 950, 952, 954, 956, 959, 961, 963, 965, 967, 970, 972, 974, 976, 979, 981, 983, 985, 988, 990, 992, 994, 997, 999, 1001, 1003, 1005, 1007, 1010, 1012, 1014, 1016, 1019, 1021, 1023, 1026, 1028, 1030, 1032, 1035, 1037, 1039, 1041, 1043, 1046, 1048, 1050, 1052, 1055, 1057, 1059, 1061, 1063, 1066, 1068, 1070, 1072, 1075, 1077, 1079, 1081, 1084, 1086, 1088, 1090, 1092, 1095, 1097, 1099, 1101, 1103, 1106, 1108, 1110, 1112, 1115, 1117, 1119, 1121, 1124, 1126, 1128, 1130, 1132, 1135, 1137, 1139, 1141, 1143, 1146, 1148, 1150, 1152, 1154, 1157, 1159, 1161, 1163, 1165, 1168, 1170, 1172, 1174, 1176, 1179, 1181, 1183, 1185, 1187, 1190, 1192, 1194, 1196, 1198, 1200, 1203, 1205, 1207, 1209, 1212, 1214, 1216, 1218, 1220, 1223, 1225, 1227, 1229, 1231, 1233, 1236, 1238, 1240, 1242, 1245, 1247, 1249, 1251, 1253, 1255, 1257, 1260, 1262, 1264, 1266, 1268, 1270, 1272, 1275, 1277, 1279, 1281, 1283, 1286, 1288, 1290, 1292, 1294, 1297, 1299, 1301, 1303, 1306, 1308, 1310, 1312, 1314, 1317, 1319, 1321, 1323, 1325, 1328, 1330, 1332, 1334, 1336, 1338, 1341, 1343, 1345, 1347, 1349, 1352, 1354, 1356, 1358, 1360, 1362, 1365, 1367, 1369, 1371, 1374, 1376, 1378, 1380, 1383, 1385, 1387, 1389, 1392, 1394, 1396, 1398, 1400, 1403, 1405, 1407, 1409, 1411, 1413, 1416, 1418, 1420, 1422, 1424, 1426, 1428, 1431, 1433, 1435, 1437, 1439, 1441, 1443, 1446, 1448, 1450, 1452, 1454, 1456, 1459, 1461, 1463, 1465, 1467, 1469, 1472, 1474, 1476, 1478, 1480, 1482, 1484, 1487, 1489, 1491, 1493, 1495, 1497, 1499, 1501, 1503, 1506, 1508, 1510, 1512, 1514, 1517, 1519, 1521, 1523, 1525, 1527, 1530, 1532, 1534, 1536, 1538, 1540, 1542, 1545, 1547, 1549, 1551, 1553, 1555, 1557, 1559, 1562, 1564, 1566, 1568, 1570, 1572, 1574, 1577, 1579, 1581, 1583, 1585, 1587, 1590, 1592, 1594, 1596, 1598, 1600, 1602, 1604, 1606, 1608, 1611, 1613, 1615, 1617, 1619, 1621, 1623, 1625, 1627, 1629, 1631, 1633, 1635, 1637, 1639, 1641, 1643, 1645, 1647, 1649, 1651, 1653, 1655, 1657, 1659, 1661, 1663, 1665, 1667, 1669, 1671, 1672, 1674, 1676, 1678, 1680, 1682, 1684, 1686, 1688, 1690, 1692, 1694, 1695, 1698, 1698, 1698, 1698, 1710, 1713, 1716, 1719, 1719, 1719, 1726, 1733, 1737, 1737, 1737, 1737], "type": "time", "resolution": "high", "original_size": 772, "series_type": "time"}]
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
View File
@@ -90,6 +90,9 @@ def mocked_requests(*args, **kwargs):
stravatimejson = json.load(open('rowers/testdata/stravatimetestdata.txt','r'))
stravavelojson = json.load(open('rowers/testdata/stravavelotestdata.txt','r'))
stravapowerjson = json.load(open('rowers/testdata/stravapowertestdata.txt','r'))
stravadistancejson = json.load(open('rowers/testdata/stravadistancetestdata.txt','r'))
stravalatlongjson = json.load(open('rowers/testdata/stravalatlongtestdata.txt','r'))
stravahrjson = json.load(open('rowers/testdata/stravahrtestdata.txt','r'))
@@ -106,6 +109,7 @@ def mocked_requests(*args, **kwargs):
'latlng':stravalatlongjson,
'heartrate':stravahrjson,
'cadence':stravaspmjson,
'power':stravapowerjson,
}
ststrokesjson = json.load(open('rowers/testdata/sporttracksstrokedata.txt','r'))
+24 -10
View File
@@ -14723,15 +14723,14 @@ def plannedsession_teamedit_view(request,
'plannedsessions':sps,
})
@user_passes_test(iscoachmember,login_url="/rowers/promembership/",
redirect_field_name=None)
#@user_passes_test(iscoachmember,login_url="/rowers/promembership/",
# redirect_field_name=None)
def plannedsessions_coach_view(request,
teamid=0,userid=0):
therower = getrower(request.user)
startdate,enddate = get_dates_timeperiod(request)
@@ -14745,14 +14744,21 @@ def plannedsessions_coach_view(request,
theteam = False
else:
theteam = False
sps = get_sessions_manager(request.user,teamid=teamid,
enddate=enddate,
startdate=startdate)
rowers = []
if request.user.rower.rowerplan == 'coach':
sps = get_sessions_manager(request.user,teamid=teamid,
enddate=enddate,
startdate=startdate)
else:
rteams = therower.team.filter(viewing='allmembers')
sps = get_sessions(therower,startdate=startdate,enddate=enddate)
rowers = [therower]
for ps in sps:
rowers += ps.rower.all()
if request.user.rower.rowerplan == 'coach':
rowers += ps.rower.all()
else:
rowers += ps.rower.filter(team__in=rteams)
rowers = list(set(rowers))
@@ -14760,14 +14766,17 @@ def plannedsessions_coach_view(request,
for ps in sps:
rowerstatus = {}
rowercolor = {}
for r in rowers:
ratio, status,completiondate = is_session_complete(r,ps)
rowerstatus[r.id] = status
rowercolor[r.id] = cratiocolors[status]
sessiondict = {
'id': ps.id,
'results':rowerstatus,
'name': ps.name,
'startdate': ps.startdate,
'color': rowercolor,
'preferreddate': ps.preferreddate,
'enddate': ps.enddate,
}
@@ -14818,6 +14827,8 @@ def plannedsessions_coach_view(request,
}
)
from rowers.plannedsessions import cratiocolors
@login_required()
def plannedsessions_view(request,
userid=0,startdatestring='',enddatestring=''):
@@ -14857,6 +14868,7 @@ def plannedsessions_view(request,
completeness = {}
actualvalue = {}
completiondate = {}
sessioncolor = {}
if not sps and request.user.rower.rowerplan == 'basic':
messages.error(request,
@@ -14866,6 +14878,7 @@ def plannedsessions_view(request,
ratio,status,cdate = is_session_complete(r,ps)
actualvalue[ps.id] = int(ps.sessionvalue*ratio)
completeness[ps.id] = status
sessioncolor[ps.id] = cratiocolors[status]
ws = Workout.objects.filter(user=r,plannedsession=ps)
completiondate[ps.id] = cdate
@@ -14901,6 +14914,7 @@ def plannedsessions_view(request,
'rower':r,
'timeperiod':timeperiod,
'completeness':completeness,
'sessioncolor':sessioncolor,
'actualvalue':actualvalue,
'completiondate':completiondate,
'unmatchedworkouts':unmatchedworkouts,
+56
View File
@@ -389,6 +389,62 @@ th.rotate > div > span {
color: #a9c08c;
}
.lightgreen {
background: #e2f0da;
color: #fdffc;
border: solid 1px #b2bfaa;
}
.lightgreen:active {
color: #f5faf2;
}
.lightgreen:hover {
background: #b2bfaa;
}
.mediumgreen {
background: #aad090;
color: #fafff7;
border: solid 1px #8db374;
}
.mediumgreen:active {
color: #d8e6cf;
}
.mediumgreen:hover {
background: #8db374;
}
.purple {
background: #8c1ec1;
color: #e9ddf0;
border: solid 1px #6b0f99;
}
.purple:active {
color: #cfa160;
}
.purple:hover {
background: #6b0f99;
}
.violet {
background: #c20d60;
color: #f0dae5;
border: solid 1px #99034e;
}
.violet:active {
color: #e595bd;
}
.violet:hover {
background: #99034e;
}
.blue {
color: #fae7e9;
border: solid 1px #27aae2;