diff --git a/rowers/dataprep.py b/rowers/dataprep.py
index e5a5806c..87029e4a 100644
--- a/rowers/dataprep.py
+++ b/rowers/dataprep.py
@@ -2353,7 +2353,20 @@ def workout_trimp(w):
r.hrftp = int(hrftp)
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(
queuehigh,
diff --git a/rowers/tasks.py b/rowers/tasks.py
index f53d6dda..374cd509 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -597,7 +597,10 @@ def handle_calctrimp(id,
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()
diff --git a/rowers/templates/gdpr_optin.html b/rowers/templates/gdpr_optin.html
index 19255535..311816ac 100644
--- a/rowers/templates/gdpr_optin.html
+++ b/rowers/templates/gdpr_optin.html
@@ -7,7 +7,8 @@
{% block main %}
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.
GDPR Opt-In
diff --git a/rowers/templates/registration/login.html b/rowers/templates/registration/login.html
index e2d74eb2..eef08c5e 100644
--- a/rowers/templates/registration/login.html
+++ b/rowers/templates/registration/login.html
@@ -21,14 +21,22 @@
- Forgot password?
+ Forgot password?
+
+
+
+ Register New User
+
+
+
+
-
+
diff --git a/rowers/templates/registration_form.html b/rowers/templates/registration_form.html
index bd75d942..e09e9365 100644
--- a/rowers/templates/registration_form.html
+++ b/rowers/templates/registration_form.html
@@ -1,7 +1,7 @@
{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
-{% block title %}Contact Us{% endblock title %}
+{% block title %}New User Registration{% endblock title %}
{% block meta %}
{% endblock %}
@@ -23,7 +23,8 @@
{{ form.as_table }}
Terms of Service
-
+
+
diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html
index bab556b1..97e94b79 100644
--- a/rowers/templates/virtualevent.html
+++ b/rowers/templates/virtualevent.html
@@ -8,11 +8,42 @@
{% include "monitorjobs.html" %}
{% endblock %}
+{% block og_title %}{{ race.name }}{% endblock %}
+{% block description %}Virtual Rowing Race {{ race.name }}{% endblock %}
+
+{% if racelogo %}
+{% block og_image %}
+
+
+
+
+{% endblock %}
+{% block image_src %}
+
+{% endblock %}
+{% endif %}
+
{% block main %}
{{ race.name }}
+
+
+
+
+
+
+
+
{% if not racelogo and race.manager == request.user %}
Add Race Logo
{% endif %}
@@ -95,9 +126,14 @@
{% if request.user.is_anonymous %}
-
- 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.
+ {% if race.sessiontype == 'race' %}
+ Register
+ {% else %}
+ Register
+ {% endif %}
+
{% else %}
See race rules below. Participation to this race is free,
@@ -108,9 +144,9 @@
{% if button == 'registerbutton' %}
{% if race.sessiontype == 'race' %}
- Register
+ Register
{% else %}
- Register
+ Register
{% endif %}
{% endif %}
diff --git a/rowers/templates/workout_view.html b/rowers/templates/workout_view.html
index 852444d6..33d7856d 100644
--- a/rowers/templates/workout_view.html
+++ b/rowers/templates/workout_view.html
@@ -11,11 +11,10 @@
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
{% block og_description %}{{ workout.name }}
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
-{% if graphs1 %}
-{% endif %}
-{% for graph in graphs1 %}
+
+{% for graph in graphs %}
{% block og_image %}
-{% if graphs1 %}
+{% if graphs %}
{% for graph in graphs %}
diff --git a/rowers/tests.py b/rowers/tests.py
index 3a1b2dd8..1171ada4 100644
--- a/rowers/tests.py
+++ b/rowers/tests.py
@@ -52,6 +52,7 @@ class DjangoTestCase(TestCase, MockTestCase):
MockTestCase.tearDown(self)
delete_strokedata(1)
+# to be done add polar mocks (for email processing)
def mocked_requests(*args, **kwargs):
with open('rowers/testdata/c2jsonworkoutdata.txt','r') as infile:
c2workoutdata = json.load(infile)
@@ -59,8 +60,12 @@ def mocked_requests(*args, **kwargs):
with open('rowers/testdata/c2jsonstrokedata.txt','r') as infile:
c2strokedata = json.load(infile)
+ polar_json = {
+ 'available-user-data': []
+ }
+
c2workoutlist = json.load(open('rowers/testdata/c2workoutlist.txt'))
-
+
c2uploadjson = {
"data": {
"id": 339,
@@ -151,6 +156,7 @@ def mocked_requests(*args, **kwargs):
if not args:
return MockSession()
+ polartester = re.compile('.*?polaraccesslink\.com')
c2tester = re.compile('.*?log\.concept2\.com')
stravatester = re.compile('.*?strava\.com')
sttester = re.compile('.*?sporttracks\.mobi')
@@ -213,6 +219,10 @@ def mocked_requests(*args, **kwargs):
tpuploadregex = '.*?trainingpeaks\.com\/v1\/file'
tpuploadtester = re.compile(tpuploadregex)
+ if polartester.match(args[0]):
+ json_data = polar_json
+ return MockResponse(json_data,200)
+
if tptester.match(args[0]):
if 'token' in args[0]:
json_data = {
@@ -959,6 +969,7 @@ class NewUserRegistrationTest(TestCase):
'tos':True,
'weightcategory':'hwt',
'sex':'male',
+ 'next':'/rowers/list-workouts',
'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)
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)
from django_mailbox.models import Mailbox,MessageAttachment,Message
@@ -1066,7 +1077,8 @@ boattype: 4x
if not os.path.isdir(path):
os.remove(path)
- def test_emailprocessing(self):
+ @patch('requests.get', side_effect=mocked_requests)
+ def test_emailprocessing(self, mock_get):
out = StringIO()
call_command('processemail', stdout=out,testing=True)
self.assertIn('Successfully processed email attachments',out.getvalue())
diff --git a/rowers/views.py b/rowers/views.py
index 88636c8e..8088b67d 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -1028,6 +1028,9 @@ def add_defaultfavorites(r):
# User registration
def rower_register_view(request):
+
+ nextpage = request.GET.get('next','/rowers/list-workouts/')
+
if request.method == 'POST':
#form = RegistrationFormUniqueEmail(request.POST)
form = RegistrationFormSex(request.POST)
@@ -1040,6 +1043,7 @@ def rower_register_view(request):
sex = form.cleaned_data['sex']
birthdate = form.cleaned_data['birthdate']
weightcategory = form.cleaned_data['weightcategory']
+ nextpage = request.POST['next']
theuser = User.objects.create_user(username,password=password)
theuser.first_name = first_name
theuser.last_name = last_name
@@ -1088,17 +1092,23 @@ def rower_register_view(request):
'Rowsandall Server
',
['roosendaalsander@gmail.com'])
- return HttpResponseRedirect('/rowers/register/thankyou/')
+ theuser = authenticate(username=username,password=password)
+ login(request,theuser)
+
+ return HttpResponseRedirect(nextpage)
+ # '/rowers/register/thankyou/')
else:
return render(request,
"registration_form.html",
- {'form':form})
+ {'form':form,
+ 'next':nextpage,})
else:
form = RegistrationFormSex()
return render(request,
"registration_form.html",
- {'form':form,})
+ {'form':form,
+ 'next':nextpage,})
# Shows analysis page
@login_required()
@@ -6963,6 +6973,9 @@ def workouts_view(request,message='',successmessage='',
if rankingonly:
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')
if query:
@@ -7012,6 +7025,7 @@ def workouts_view(request,message='',successmessage='',
'name':'Workouts'
},
]
+
return render(request, 'list_workouts.html',
{'workouts': workouts,
'active': 'nav-workouts',
diff --git a/templates/newbase.html b/templates/newbase.html
index 6f6a1c7c..755e5667 100644
--- a/templates/newbase.html
+++ b/templates/newbase.html
@@ -157,7 +157,7 @@
{% elif user.rower.rowerplan == 'plan' %}
{% else %}
-
+
{% endif %}
diff --git a/templates/newbasefront.html b/templates/newbasefront.html
index 97cba250..85abb700 100644
--- a/templates/newbasefront.html
+++ b/templates/newbasefront.html
@@ -173,7 +173,7 @@
{% elif user.rower.rowerplan == 'plan' %}
{% else %}
-
+
{% endif %}