Merge branch 'release/v8.56'
This commit is contained in:
@@ -32,6 +32,7 @@ oauth_data = {
|
||||
'expirydatename': 'tokenexpirydate',
|
||||
'bearer_auth': True,
|
||||
'base_url': "https://log.concept2.com/oauth/access_token",
|
||||
'scope':'write',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1251,7 +1251,10 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
||||
data.to_sql('strokedata',engine,if_exists='append',index=False)
|
||||
except:
|
||||
data.drop(columns=['rhythm'],inplace=True)
|
||||
data.to_sql('strokedata',engine,if_exists='append',index=False)
|
||||
try:
|
||||
data.to_sql('strokedata',engine,if_exists='append',index=False)
|
||||
except:
|
||||
pass
|
||||
|
||||
conn.close()
|
||||
engine.dispose()
|
||||
|
||||
+3
-1
@@ -216,6 +216,8 @@ def imports_get_token(
|
||||
if 'grant_type' in oauth_data:
|
||||
if oauth_data['grant_type']:
|
||||
post_data['grant_type'] = oauth_data['grant_type']
|
||||
if 'strava' in oauth_data['autorization_uri']:
|
||||
post_data['grant_type'] = "authorization_code"
|
||||
else:
|
||||
grant_type = post_data.pop('grant_type',None)
|
||||
|
||||
@@ -265,7 +267,7 @@ def imports_make_authorization_url(oauth_data):
|
||||
params = {"client_id": oauth_data['client_id'],
|
||||
"response_type": "code",
|
||||
"redirect_uri": oauth_data['redirect_uri'],
|
||||
"scope":"write",
|
||||
"scope":oauth_data['scope'],
|
||||
"state":state}
|
||||
|
||||
|
||||
|
||||
+18
-2
@@ -2091,7 +2091,8 @@ class Workout(models.Model):
|
||||
|
||||
user = models.ForeignKey(Rower)
|
||||
team = models.ManyToManyField(Team,blank=True)
|
||||
plannedsession = models.ForeignKey(PlannedSession, blank=True,null=True)
|
||||
plannedsession = models.ForeignKey(PlannedSession, blank=True,null=True,
|
||||
verbose_name='Session')
|
||||
name = models.CharField(max_length=150,blank=True,null=True)
|
||||
date = models.DateField()
|
||||
workouttype = models.CharField(choices=workouttypes,max_length=50,
|
||||
@@ -2452,7 +2453,7 @@ class WorkoutForm(ModelForm):
|
||||
# duration = forms.TimeInput(format='%H:%M:%S.%f')
|
||||
class Meta:
|
||||
model = Workout
|
||||
fields = ['name','date','starttime','timezone','duration','distance','workouttype','boattype','weightcategory','notes','rankingpiece','duplicate']
|
||||
fields = ['name','date','starttime','timezone','duration','distance','workouttype','boattype','weightcategory','notes','rankingpiece','duplicate','plannedsession']
|
||||
widgets = {
|
||||
'date': AdminDateWidget(),
|
||||
'notes': forms.Textarea,
|
||||
@@ -2475,6 +2476,21 @@ class WorkoutForm(ModelForm):
|
||||
else:
|
||||
self.fields['private'].initial = True
|
||||
|
||||
workout = self.instance
|
||||
sps = PlannedSession.objects.filter(
|
||||
rower__in=[workout.user],
|
||||
startdate__lte=workout.date,
|
||||
enddate__gte=workout.date,
|
||||
).order_by("preferreddate","startdate","enddate").exclude(
|
||||
sessiontype='race')
|
||||
|
||||
if not sps:
|
||||
del self.fields['plannedsession']
|
||||
else:
|
||||
self.fields['plannedsession'].queryset = sps
|
||||
else:
|
||||
del self.fields['plannedsession']
|
||||
|
||||
# Used for the rowing physics calculations
|
||||
class AdvancedWorkoutForm(ModelForm):
|
||||
quick_calc = forms.BooleanField(initial=True,required=False)
|
||||
|
||||
@@ -19,7 +19,8 @@ oauth_data = {
|
||||
'expirydatename': None,
|
||||
'bearer_auth': True,
|
||||
'base_url': "https://runkeeper.com/apps/token",
|
||||
'headers': {'user-agent': 'sanderroosendaal'}
|
||||
'headers': {'user-agent': 'sanderroosendaal'},
|
||||
'scope':'write',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ oauth_data = {
|
||||
'expirydatename': 'sporttrackstokenexpirydate',
|
||||
'bearer_auth': False,
|
||||
'base_url': "https://api.sporttracks.mobi/oauth2/token",
|
||||
'scope':'write',
|
||||
}
|
||||
|
||||
# Checks if user has SportTracks token, renews them if they are expired
|
||||
|
||||
@@ -33,6 +33,12 @@ except ImportError:
|
||||
|
||||
from rowers.imports import *
|
||||
|
||||
headers = {'Accept': 'application/json',
|
||||
'Api-Key': STRAVA_CLIENT_ID,
|
||||
'Content-Type': 'application/json',
|
||||
'user-agent': 'sanderroosendaal'}
|
||||
|
||||
|
||||
oauth_data = {
|
||||
'client_id': STRAVA_CLIENT_ID,
|
||||
'client_secret': STRAVA_CLIENT_SECRET,
|
||||
@@ -45,6 +51,8 @@ oauth_data = {
|
||||
'bearer_auth': True,
|
||||
'base_url': "https://www.strava.com/oauth/token",
|
||||
'grant_type': 'refresh_token',
|
||||
'headers': headers,
|
||||
'scope':'activity:write,activity:read_all',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -610,6 +610,7 @@ def handle_calctrimp(id,
|
||||
intensityfactor = normp/float(ftp)
|
||||
tss = 100.*((duration*normp*intensityfactor)/(3600.*ftp))
|
||||
|
||||
|
||||
if sex == 'male':
|
||||
f = 1.92
|
||||
else:
|
||||
@@ -646,6 +647,24 @@ def handle_calctrimp(id,
|
||||
if not np.isfinite(normw):
|
||||
normw = 0
|
||||
|
||||
try:
|
||||
dum = int(tss)
|
||||
except ValueError:
|
||||
tss = 0
|
||||
|
||||
try:
|
||||
dum = int(normp)
|
||||
except ValueError:
|
||||
normp = 0
|
||||
try:
|
||||
dump = int(trimp)
|
||||
except ValueError:
|
||||
trimp = 0
|
||||
try:
|
||||
dump = int(hrtss)
|
||||
except ValueError:
|
||||
hrtss = 0
|
||||
|
||||
query = 'UPDATE rowers_workout SET rscore = {tss}, normp = {normp}, trimp={trimp}, hrtss={hrtss}, normv={normv}, normw={normw} WHERE id={id}'.format(
|
||||
tss = int(tss),
|
||||
normp = int(normp),
|
||||
|
||||
@@ -5,13 +5,18 @@
|
||||
{% block title %}GDPR Opt-In{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<p>
|
||||
We know you are eager to start using rowsandall.com, but we must
|
||||
ask you to read and agree with the below first.
|
||||
</p>
|
||||
|
||||
<h2>GDPR Opt-In</h2>
|
||||
<p>
|
||||
<b>
|
||||
To comply with the European Union General Data Protection Regulation,
|
||||
we need to record your consent to use personal data on this website.
|
||||
Please take some time to review our data policies. If you agree and
|
||||
opt in, click the green button at the bottom to be taken to the site.
|
||||
opt in, click the "opt in" button at the bottom to be taken to the site.
|
||||
If you do not agree, please use the red button to delete your
|
||||
account. This will irreversibly delete all your data on rowsandall.com
|
||||
and remove your account.
|
||||
@@ -32,7 +37,7 @@
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/me/gdpr-optin-confirm/?next={{ next }}">Opt in and continue</a>
|
||||
<a class="button green small" href="/rowers/me/gdpr-optin-confirm/?next={{ next }}">Opt in and continue</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
setTimeout("location.reload(true);",60000);
|
||||
setTimeout("location.reload(true);",180000);
|
||||
</script>
|
||||
<script
|
||||
type='text/javascript'
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<li>
|
||||
<a href={{ request.path|userurl:member }}>
|
||||
<i class="fas fa-user fa-fw"></i>
|
||||
{% if member == rower.user and team.id == 0 %}
|
||||
{% if member == rower.user and not team %}
|
||||
•
|
||||
{% else %}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
<form enctype="multipart/form-data" action="" method="post">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
@@ -17,6 +17,16 @@
|
||||
{% csrf_token %}
|
||||
<input class="button green" type="submit" value="Save">
|
||||
</form>
|
||||
</p>
|
||||
<p>Click on one of the icons below to connect to the service of your
|
||||
choice or to renew the authorization</p>
|
||||
<p><a href="/rowers/me/stravaauthorize/"><img src="/static/img/ConnectWithStrava.png" alt="connect with strava" width="120"></a></p>
|
||||
<p><a href="/rowers/me/c2authorize/"><img src="/static/img/blueC2logo.png" alt="connect with Concept2" width="120"></a></p>
|
||||
<p><a href="/rowers/me/sporttracksauthorize/"><img src="/static/img/sporttracks-button.png" alt="connect with SportTracks" width="120"></a></p>
|
||||
<p><a href="/rowers/me/runkeeperauthorize/"><img src="/static/img/rk-logo.png" alt="connect with RunKeeper" width="120"></a></p>
|
||||
<p><a href="/rowers/me/underarmourauthorize/"><img src="/static/img/UAbtn.png" alt="connect with Under Armour" width="120"></a></p>
|
||||
<p><a href="/rowers/me/polarauthorize/"><img src="/static/img/Polar_connectwith_btn_white.png"
|
||||
alt="connect with Polar" width="130"></a></p>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,17 @@ $('#id_workouttype').change();
|
||||
|
||||
{% block main %}
|
||||
|
||||
<p>
|
||||
{% if workout|previousworkout:rower.user %}
|
||||
<a href="/rowers/workout/{{ workout|previousworkout:rower.user }}/edit"
|
||||
title="Jump to preceding workout"><em>Previous</em></a>
|
||||
{% endif %}
|
||||
{% if workout|nextworkout:rower.user %}
|
||||
<a href="/rowers/workout/{{ workout|nextworkout:rower.user }}/edit"
|
||||
title="Jump to following workout"><em>Next</em></a>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<h1>Edit Workout {{ workout.name }}</h1>
|
||||
<ul class="main-content">
|
||||
<li class="grid_4">
|
||||
@@ -94,7 +105,7 @@ $('#id_workouttype').change();
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<input class="button green" type="submit" value="Save">
|
||||
<input type="submit" value="Save">
|
||||
</form>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
|
||||
@@ -11,7 +11,7 @@ from rowers.utils import calculate_age
|
||||
from rowers.models import (
|
||||
course_length,WorkoutComment,
|
||||
TrainingMacroCycle,TrainingMesoCycle, TrainingMicroCycle,
|
||||
Rower
|
||||
Rower,Workout
|
||||
)
|
||||
from rowers.plannedsessions import (
|
||||
race_can_register, race_can_submit,race_rower_status
|
||||
@@ -464,4 +464,53 @@ def micromacroid(id):
|
||||
|
||||
return str(theid)
|
||||
|
||||
@register.filter
|
||||
def nextworkout(workout,user):
|
||||
if user.rower == workout.user:
|
||||
ws = Workout.objects.filter(
|
||||
startdatetime__gte=workout.startdatetime,
|
||||
user=workout.user
|
||||
).order_by(
|
||||
"startdatetime"
|
||||
).exclude(id=workout.id)
|
||||
else:
|
||||
ws = Workout.objects.filter(
|
||||
startdatetime__gte=workout.startdatetime,
|
||||
user=workout.user,privacy='visible'
|
||||
).order_by(
|
||||
"startdatetime"
|
||||
).exclude(id=workout.id)
|
||||
|
||||
|
||||
if ws:
|
||||
return ws[0].id
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
@register.filter
|
||||
def previousworkout(workout,user):
|
||||
if user.rower == workout.user:
|
||||
ws = Workout.objects.filter(
|
||||
startdatetime__lte=workout.startdatetime,
|
||||
user=workout.user
|
||||
).order_by(
|
||||
"-startdatetime"
|
||||
).exclude(id=workout.id)
|
||||
else:
|
||||
ws = Workout.objects.filter(
|
||||
startdatetime__lte=workout.startdatetime,
|
||||
user=workout.user,privacy='visible'
|
||||
).order_by(
|
||||
"-startdatetime"
|
||||
).exclude(id=workout.id)
|
||||
|
||||
|
||||
if ws:
|
||||
return ws[0].id
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ oauth_data = {
|
||||
'expirydatename': 'tptokenexpirydate',
|
||||
'bearer_auth': False,
|
||||
'base_url': "https://oauth.trainingpeaks.com/oauth/token",
|
||||
'scope':'write',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ oauth_data = {
|
||||
'expirydatename': 'underarmourtokenexpirydate',
|
||||
'bearer_auth': True,
|
||||
'base_url': "https://api.ua.com/v7.1/oauth2/access_token/",
|
||||
'scope':'write',
|
||||
}
|
||||
|
||||
# Checks if user has UnderArmour token, renews them if they are expired
|
||||
|
||||
@@ -357,7 +357,9 @@ urlpatterns = [
|
||||
url(r'^me/deactivate$',views.deactivate_user),
|
||||
url(r'^me/delete$',views.remove_user),
|
||||
url(r'^me/gdpr-optin-confirm/?$',views.user_gdpr_confirm),
|
||||
url(r'^me/gdpr-optin-confirm/$',views.user_gdpr_confirm),
|
||||
url(r'^me/gdpr-optin/?$',views.user_gdpr_optin),
|
||||
url(r'^me/gdpr-optin/$',views.user_gdpr_optin),
|
||||
url(r'^me/teams/$',views.rower_teams_view),
|
||||
url(r'^me/calcdps/$',views.rower_calcdps_view),
|
||||
url(r'^me/exportsettings/$',views.rower_exportsettings_view),
|
||||
|
||||
+24
-5
@@ -208,6 +208,7 @@ from django.core.cache import cache
|
||||
from django_mailbox.models import Message,Mailbox,MessageAttachment
|
||||
|
||||
|
||||
|
||||
# Utility to get stroke data in a JSON response
|
||||
class JSONResponse(HttpResponse):
|
||||
def __init__(self, data, **kwargs):
|
||||
@@ -2069,7 +2070,7 @@ def rower_strava_authorize(request):
|
||||
params = {"client_id": STRAVA_CLIENT_ID,
|
||||
"response_type": "code",
|
||||
"redirect_uri": STRAVA_REDIRECT_URI,
|
||||
"scope": "write"}
|
||||
"scope": "activity:write,activity:read_all"}
|
||||
|
||||
url = "https://www.strava.com/oauth/authorize?"+ urllib.urlencode(params)
|
||||
|
||||
@@ -2407,6 +2408,7 @@ def rower_process_polarcallback(request):
|
||||
def rower_process_stravacallback(request):
|
||||
try:
|
||||
code = request.GET['code']
|
||||
scope = request.GET['scope']
|
||||
except MultiValueDictKeyError:
|
||||
try:
|
||||
message = request.GET['error']
|
||||
@@ -3369,6 +3371,11 @@ def addmanual_view(request):
|
||||
avghr = metricsform.cleaned_data['avghr']
|
||||
avgpwr = metricsform.cleaned_data['avgpwr']
|
||||
avgspm = metricsform.cleaned_data['avgspm']
|
||||
try:
|
||||
ps = form.cleaned_data['plannedsession']
|
||||
except KeyError:
|
||||
ps = None
|
||||
|
||||
try:
|
||||
boattype = request.POST['boattype']
|
||||
except KeyError:
|
||||
@@ -3426,10 +3433,14 @@ def addmanual_view(request):
|
||||
w.privacy = privacy
|
||||
w.weightcategory = weightcategory
|
||||
w.notes = notes
|
||||
w.plannedsession = ps
|
||||
w.name = name
|
||||
w.workouttype = workouttype
|
||||
w.boattype = boattype
|
||||
w.save()
|
||||
if ps:
|
||||
add_workouts_plannedsession([w],ps,w.user)
|
||||
|
||||
messages.info(request,'New workout created')
|
||||
else:
|
||||
return render(request,'manualadd.html',
|
||||
@@ -6079,10 +6090,7 @@ def multiflex_data(request,userid=0,
|
||||
yerror = groups.std()[yparam]
|
||||
groupsize = groups.count()[xparam]
|
||||
|
||||
print groupsize.sum(),groupsize.mean()
|
||||
|
||||
mask = groupsize <= min([0.01*groupsize.sum(),0.2*groupsize.mean()])
|
||||
print '--------------------------'
|
||||
xvalues.loc[mask] = np.nan
|
||||
|
||||
yvalues.loc[mask] = np.nan
|
||||
@@ -9956,7 +9964,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
if request.method == 'POST':
|
||||
# Form was submitted
|
||||
form = WorkoutForm(request.POST)
|
||||
form = WorkoutForm(request.POST,instance=row)
|
||||
if form.is_valid():
|
||||
# Get values from form
|
||||
name = form.cleaned_data['name']
|
||||
@@ -9970,6 +9978,11 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
notes = form.cleaned_data['notes']
|
||||
thetimezone = form.cleaned_data['timezone']
|
||||
|
||||
try:
|
||||
ps = form.cleaned_data['plannedsession']
|
||||
except KeyError:
|
||||
ps = None
|
||||
|
||||
try:
|
||||
boattype = request.POST['boattype']
|
||||
except KeyError:
|
||||
@@ -10031,10 +10044,16 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
row.privacy = privacy
|
||||
row.rankingpiece = rankingpiece
|
||||
row.timezone = thetimezone
|
||||
row.plannedsession = ps
|
||||
|
||||
try:
|
||||
row.save()
|
||||
except IntegrityError:
|
||||
pass
|
||||
|
||||
if ps:
|
||||
add_workouts_plannedsession([row],ps,row.user)
|
||||
|
||||
# change data in csv file
|
||||
|
||||
r = rdata(row.csvfilename)
|
||||
|
||||
Reference in New Issue
Block a user