Private
Public Access
1
0

Merge branch 'release/v8.62'

This commit is contained in:
Sander Roosendaal
2018-11-29 17:27:55 +01:00
11 changed files with 111 additions and 24 deletions
+13
View File
@@ -2354,6 +2354,19 @@ def workout_trimp(w):
r.save() r.save()
if w.averagehr is None:
rowdata = rdata(w.csvfilename)
try:
avghr = rowdata.df[' HRCur (bpm)'].mean()
maxhr = rowdata.df[' HRCur (bpm)'].max()
except KeyError:
avghr = None
maxhr = None
w.averagehr = avghr
w.maxhr = maxhr
w.save()
job = myqueue( job = myqueue(
queuehigh, queuehigh,
+4 -1
View File
@@ -597,7 +597,10 @@ def handle_calctrimp(id,
df = rowdata.df df = rowdata.df
df['deltat'] = df[' ElapsedTime (sec)'].diff().abs() try:
df['deltat'] = df[' ElapsedTime (sec)'].diff().abs()
except KeyError:
return 0
df2 = df.copy() df2 = df.copy()
+2 -1
View File
@@ -7,7 +7,8 @@
{% block main %} {% block main %}
<p> <p>
We know you are eager to start using rowsandall.com, but we must We know you are eager to start using rowsandall.com, but we must
ask you to read and agree with the below first. ask you to read and agree with the below first. At the bottom of this page,
you can opt in or delete this user account.
</p> </p>
<h2>GDPR Opt-In</h2> <h2>GDPR Opt-In</h2>
+10 -2
View File
@@ -21,14 +21,22 @@
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td><a href="/password_reset/">Forgot password?</a></td> <td><p><a href="/password_reset/">Forgot password?</a></p></td>
</tr>
<tr>
<td></td>
<td><p><a href="/rowers/register?next={{ next }}">Register New User</a></p></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="login" /></td>
</tr> </tr>
</table> </table>
<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" /> <input type="hidden" name="next" value="{{ next }}" />
</form> </form>
</li> </li>
+3 -2
View File
@@ -1,7 +1,7 @@
{% extends "newbase.html" %} {% extends "newbase.html" %}
{% load staticfiles %} {% load staticfiles %}
{% load rowerfilters %} {% load rowerfilters %}
{% block title %}Contact Us{% endblock title %} {% block title %}New User Registration{% endblock title %}
{% block meta %} {% block meta %}
{% endblock %} {% endblock %}
@@ -23,7 +23,8 @@
{{ form.as_table }} {{ form.as_table }}
</table> </table>
<a href="/rowers/legal">Terms of Service</a> <a href="/rowers/legal">Terms of Service</a>
<input class="button green" type="submit" value="Submit"> <input type="hidden" name="next" value="{{ next }}"/>
<input type="submit" value="Submit">
</form> </form>
</div> </div>
</li> </li>
+41 -5
View File
@@ -8,11 +8,42 @@
{% include "monitorjobs.html" %} {% include "monitorjobs.html" %}
{% endblock %} {% endblock %}
{% block og_title %}{{ race.name }}{% endblock %}
{% block description %}Virtual Rowing Race {{ race.name }}{% endblock %}
{% if racelogo %}
{% block og_image %}
<meta property="og:image" content="http://rowsandall.com/{{ racelogo.filename|spacetohtml }}" />
<meta property="og:image:secure_url" content="https://rowsandall.com/{{ racelogo.filename |spacetohtml }}" />
<meta property="og:image:width" content="{{ racelogo.width }}" />
<meta property="og:image:height" content="{{ racelogo.height }}" />
{% endblock %}
{% block image_src %}
<link rel="image_src" href="/{{ racelogo.filename |spacetohtml }}" />
{% endblock %}
{% endif %}
{% block main %} {% block main %}
<h1>{{ race.name }}</h1> <h1>{{ race.name }}</h1>
<p>
<div class="fb-share-button"
data-href="{{ request.build_absolute_uri }}"
data-layout="button" data-size="small" data-mobile-iframe="false">
<a class="fb-xfbml-parse-ignore" target="_blank"
href="https://www.facebook.com/sharer/sharer.php?u={{ request.build_absolute_uri }}">Share</a>
</div>
</p>
<p>
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet"
data-url="{{ request.build_absolute_uri }}"
data-text="@rowsandall #rowingdata Participate in Indoor Rowing virtual race '{{ race.name }}'">Tweet</a>
</p>
{% if not racelogo and race.manager == request.user %} {% if not racelogo and race.manager == request.user %}
<a href="/rowers/virtualevent/{{ race.id }}/image">Add Race Logo</a> <a href="/rowers/virtualevent/{{ race.id }}/image">Add Race Logo</a>
{% endif %} {% endif %}
@@ -95,9 +126,14 @@
</div> </div>
<div id="registerbuttons"> <div id="registerbuttons">
{% if request.user.is_anonymous %} {% if request.user.is_anonymous %}
<p> <p>
Registered users of rowsandall.com can participate in this event. Participation is free, unless specified differently in the race comment above. Registered users of rowsandall.com can participate in this event. Participation is free, unless specified differently in the race comment above.
</p> {% if race.sessiontype == 'race' %}
<a href="/rowers/virtualevent/{{ race.id }}/register"><h3>Register</h3></a>
{% else %}
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor"><h3>Register</h3></a>
{% endif %}
</p>
{% else %} {% else %}
<p> <p>
See race rules below. Participation to this race is free, See race rules below. Participation to this race is free,
@@ -108,9 +144,9 @@
{% if button == 'registerbutton' %} {% if button == 'registerbutton' %}
<p> <p>
{% if race.sessiontype == 'race' %} {% if race.sessiontype == 'race' %}
<a href="/rowers/virtualevent/{{ race.id }}/register">Register</a> <a href="/rowers/virtualevent/{{ race.id }}/register"><h3>Register</h3></a>
{% else %} {% else %}
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor">Register</a> <a href="/rowers/virtualevent/{{ race.id }}/registerindoor"><h3>Register</h3></a>
{% endif %} {% endif %}
</p> </p>
{% endif %} {% endif %}
+3 -4
View File
@@ -11,11 +11,10 @@
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %} {{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
{% block og_description %}{{ workout.name }} {% block og_description %}{{ workout.name }}
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %} {{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
{% if graphs1 %}
{% endif %} {% for graph in graphs %}
{% for graph in graphs1 %}
{% block og_image %} {% block og_image %}
{% if graphs1 %} {% if graphs %}
{% for graph in graphs %} {% for graph in graphs %}
<meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" /> <meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" />
<meta property="og:image:secure_url" content="https://rowsandall.com/{{ graph.filename |spacetohtml }}" /> <meta property="og:image:secure_url" content="https://rowsandall.com/{{ graph.filename |spacetohtml }}" />
+14 -2
View File
@@ -52,6 +52,7 @@ class DjangoTestCase(TestCase, MockTestCase):
MockTestCase.tearDown(self) MockTestCase.tearDown(self)
delete_strokedata(1) delete_strokedata(1)
# to be done add polar mocks (for email processing)
def mocked_requests(*args, **kwargs): def mocked_requests(*args, **kwargs):
with open('rowers/testdata/c2jsonworkoutdata.txt','r') as infile: with open('rowers/testdata/c2jsonworkoutdata.txt','r') as infile:
c2workoutdata = json.load(infile) c2workoutdata = json.load(infile)
@@ -59,6 +60,10 @@ def mocked_requests(*args, **kwargs):
with open('rowers/testdata/c2jsonstrokedata.txt','r') as infile: with open('rowers/testdata/c2jsonstrokedata.txt','r') as infile:
c2strokedata = json.load(infile) c2strokedata = json.load(infile)
polar_json = {
'available-user-data': []
}
c2workoutlist = json.load(open('rowers/testdata/c2workoutlist.txt')) c2workoutlist = json.load(open('rowers/testdata/c2workoutlist.txt'))
c2uploadjson = { c2uploadjson = {
@@ -151,6 +156,7 @@ def mocked_requests(*args, **kwargs):
if not args: if not args:
return MockSession() return MockSession()
polartester = re.compile('.*?polaraccesslink\.com')
c2tester = re.compile('.*?log\.concept2\.com') c2tester = re.compile('.*?log\.concept2\.com')
stravatester = re.compile('.*?strava\.com') stravatester = re.compile('.*?strava\.com')
sttester = re.compile('.*?sporttracks\.mobi') sttester = re.compile('.*?sporttracks\.mobi')
@@ -213,6 +219,10 @@ def mocked_requests(*args, **kwargs):
tpuploadregex = '.*?trainingpeaks\.com\/v1\/file' tpuploadregex = '.*?trainingpeaks\.com\/v1\/file'
tpuploadtester = re.compile(tpuploadregex) tpuploadtester = re.compile(tpuploadregex)
if polartester.match(args[0]):
json_data = polar_json
return MockResponse(json_data,200)
if tptester.match(args[0]): if tptester.match(args[0]):
if 'token' in args[0]: if 'token' in args[0]:
json_data = { json_data = {
@@ -959,6 +969,7 @@ class NewUserRegistrationTest(TestCase):
'tos':True, 'tos':True,
'weightcategory':'hwt', 'weightcategory':'hwt',
'sex':'male', 'sex':'male',
'next':'/rowers/list-workouts',
'birthdate':datetime.datetime(year=1970,month=4,day=2) 'birthdate':datetime.datetime(year=1970,month=4,day=2)
} }
@@ -968,7 +979,7 @@ class NewUserRegistrationTest(TestCase):
response = self.c.post('/rowers/register', form_data, follow=True) response = self.c.post('/rowers/register', form_data, follow=True)
self.assertRedirects(response, self.assertRedirects(response,
expected_url='/rowers/register/thankyou/', expected_url='/rowers/me/gdpr-optin/?next=/rowers/list-workouts/',
status_code=302,target_status_code=200) status_code=302,target_status_code=200)
from django_mailbox.models import Mailbox,MessageAttachment,Message from django_mailbox.models import Mailbox,MessageAttachment,Message
@@ -1066,7 +1077,8 @@ boattype: 4x
if not os.path.isdir(path): if not os.path.isdir(path):
os.remove(path) os.remove(path)
def test_emailprocessing(self): @patch('requests.get', side_effect=mocked_requests)
def test_emailprocessing(self, mock_get):
out = StringIO() out = StringIO()
call_command('processemail', stdout=out,testing=True) call_command('processemail', stdout=out,testing=True)
self.assertIn('Successfully processed email attachments',out.getvalue()) self.assertIn('Successfully processed email attachments',out.getvalue())
+17 -3
View File
@@ -1028,6 +1028,9 @@ def add_defaultfavorites(r):
# User registration # User registration
def rower_register_view(request): def rower_register_view(request):
nextpage = request.GET.get('next','/rowers/list-workouts/')
if request.method == 'POST': if request.method == 'POST':
#form = RegistrationFormUniqueEmail(request.POST) #form = RegistrationFormUniqueEmail(request.POST)
form = RegistrationFormSex(request.POST) form = RegistrationFormSex(request.POST)
@@ -1040,6 +1043,7 @@ def rower_register_view(request):
sex = form.cleaned_data['sex'] sex = form.cleaned_data['sex']
birthdate = form.cleaned_data['birthdate'] birthdate = form.cleaned_data['birthdate']
weightcategory = form.cleaned_data['weightcategory'] weightcategory = form.cleaned_data['weightcategory']
nextpage = request.POST['next']
theuser = User.objects.create_user(username,password=password) theuser = User.objects.create_user(username,password=password)
theuser.first_name = first_name theuser.first_name = first_name
theuser.last_name = last_name theuser.last_name = last_name
@@ -1088,17 +1092,23 @@ def rower_register_view(request):
'Rowsandall Server <info@rowsandall.com>', 'Rowsandall Server <info@rowsandall.com>',
['roosendaalsander@gmail.com']) ['roosendaalsander@gmail.com'])
return HttpResponseRedirect('/rowers/register/thankyou/') theuser = authenticate(username=username,password=password)
login(request,theuser)
return HttpResponseRedirect(nextpage)
# '/rowers/register/thankyou/')
else: else:
return render(request, return render(request,
"registration_form.html", "registration_form.html",
{'form':form}) {'form':form,
'next':nextpage,})
else: else:
form = RegistrationFormSex() form = RegistrationFormSex()
return render(request, return render(request,
"registration_form.html", "registration_form.html",
{'form':form,}) {'form':form,
'next':nextpage,})
# Shows analysis page # Shows analysis page
@login_required() @login_required()
@@ -6963,6 +6973,9 @@ def workouts_view(request,message='',successmessage='',
if rankingonly: if rankingonly:
workouts = workouts.exclude(rankingpiece=False) workouts = workouts.exclude(rankingpiece=False)
workoutsnohr = workouts.exclude(averagehr__isnull=False)
for w in workoutsnohr:
res = dataprep.workout_trimp(w)
query = request.GET.get('q') query = request.GET.get('q')
if query: if query:
@@ -7012,6 +7025,7 @@ def workouts_view(request,message='',successmessage='',
'name':'Workouts' 'name':'Workouts'
}, },
] ]
return render(request, 'list_workouts.html', return render(request, 'list_workouts.html',
{'workouts': workouts, {'workouts': workouts,
'active': 'nav-workouts', 'active': 'nav-workouts',
+1 -1
View File
@@ -157,7 +157,7 @@
{% elif user.rower.rowerplan == 'plan' %} {% elif user.rower.rowerplan == 'plan' %}
<i class="fas fa-user-chart "></i> <i class="fas fa-user-chart "></i>
{% else %} {% else %}
<a href="/rowers/me/edit" title="Profile"> <a href="/rowers/me/preferences" title="Profile">
<i class="fas fa-user"></i> <i class="fas fa-user"></i>
{% endif %} {% endif %}
</a> </a>
+1 -1
View File
@@ -173,7 +173,7 @@
{% elif user.rower.rowerplan == 'plan' %} {% elif user.rower.rowerplan == 'plan' %}
<i class="fas fa-user-tie "></i> <i class="fas fa-user-tie "></i>
{% else %} {% else %}
<a href="/rowers/me/edit" title="Profile"> <a href="/rowers/me/preferences" title="Profile">
<i class="fas fa-user"></i> <i class="fas fa-user"></i>
{% endif %} {% endif %}
</a> </a>