Private
Public Access
1
0

Merge branch 'release/v6.33'

This commit is contained in:
Sander Roosendaal
2018-03-23 14:27:29 +01:00
8 changed files with 152 additions and 61 deletions
+14 -16
View File
@@ -33,25 +33,23 @@ queuelow = django_rq.get_queue('low')
queuehigh = django_rq.get_queue('default')
# Sends a confirmation with a link to the workout
from rowers.emails import send_template_email
def send_confirm(user, name, link, options):
""" Send confirmation email to user when email has been processed """
d = {
'first_name':user.first_name,
'name':name,
'link':link,
}
fullemail = user.email
subject = 'Workout added: ' + name
message = 'Dear ' + user.first_name + ',\n\n'
message += "Your workout has been added to Rowsandall.com.\n"
message += "Link to workout: " + link + "\n\n"
message += "Best Regards, the Rowsandall Team"
if options:
message += "\n\n" + str(options)
email = EmailMessage(subject, message,
'Rowsandall <info@rowsandall.com>',
[fullemail])
res = email.send()
subject = 'New Workout Added: '+name
res = send_template_email('Rowsandall <info@rowsandall.com>',
[fullemail],
subject,'confirmemail.html',
d
)
return 1
+7 -8
View File
@@ -84,7 +84,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
imagename=imagename
)
try:
if workoutid and not testing:
if workoutid:
email_sent = send_confirm(
rower.user, title, link,
uploadoptions
@@ -92,13 +92,12 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
time.sleep(10)
except:
try:
if not testing:
time.sleep(10)
if workoutid:
email_sent = send_confirm(
rower.user, title, link,
uploadoptions
)
time.sleep(10)
if workoutid:
email_sent = send_confirm(
rower.user, title, link,
uploadoptions
)
except:
pass
+4 -1
View File
@@ -303,7 +303,10 @@ def handle_stravaexport(f2,workoutname,stravatoken,description='',
# w = Workout.objects.get(id=workoutid)
client = stravalib.Client(access_token=stravatoken)
act = client.upload_activity(f2,'tcx.gz',name=workoutname)
try:
act = client.upload_activity(f2,'tcx.gz',name=workoutname)
except:
return {0,'Strava upload failed'}
try:
res = act.wait(poll_interval=5.0,timeout=30)
message = 'Workout successfully synchronized to Strava'
+18
View File
@@ -0,0 +1,18 @@
{% extends "emailbase.html" %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
Your workout has been added to Rowsandall.com.
</p>
<p>
Link to workout: {{ link }}
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}
+55
View File
@@ -0,0 +1,55 @@
{% extends "emailbase.html" %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
Thank you for registering on rowsandall.com.
You can now login using the credentials you provided.
The first thing you should do is go to the
<a href="https://rowsandall.com/rowers/me/edit/">Settings page</a>
and make yourself familiar with the various options
available to personalize your experience on the website.
To get there, use the link in the email or click the button
with your first name on it in the upper right corner of the opening page.
</p>
<p>
As a minimum to get you started, enter your data in the
Heart Rate Zones and Power Zones sections and your
Functional Threshold Power.
Then check your Account Information to make sure it is
accurate and reflects your preferences.
</p>
<p>
For additional details on these settings and
the buttons at the bottom of the page, read
the settings tutorial at
<a href="http://analytics.rowsandall.com/2017/11/02/rowsandall-settings-page-tutorial/">http://analytics.rowsandall.com/2017/11/02/rowsandall-settings-page-tutorial/</a>.
<p>
<p>
Also check out our instructional videos at
<a href="http://rowsandall.com/rowers/videos">http://rowsandall.com/rowers/videos</a>
</p>
<p>
This website is a labor of love "by rowers, for rowers".
If you find it to be useful, please help us cover
our hosting costs and gain access to additional functionality
by signing on as a Pro member:
<a href="https://rowsandall.com/rowers/promembership">https://rowsandall.com/rowers/promembership</a>
</p>
<p>
Oh, one more thing. The site is currently in beta and is
developing fast. Bear with us. Don't hesitate to
contact me at info@rowsandall.com if anything is broken
or doesn't seem to work as advertised.
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}
+45 -19
View File
@@ -10,6 +10,7 @@ import rowers.interactiveplots as iplots
import datetime
from rowingdata import rowingdata as rdata
from rowingdata import rower as rrower
from django.utils import timezone
from rowers.rows import handle_uploaded_file
from django.core.files.uploadedfile import SimpleUploadedFile
from time import strftime,strptime,mktime,time,daylight
@@ -68,7 +69,9 @@ class C2Objects(DjangoTestCase):
u.first_name = 'John'
u.last_name = 'Sander'
u.save()
r = Rower.objects.create(user=u)
r = Rower.objects.create(user=u,gdproptin=True,
gdproptindate=timezone.now()
)
res = add_workout_from_strokedata(u,1,data,strokedata,source='c2')
@@ -91,7 +94,10 @@ class C2Objects(DjangoTestCase):
u.first_name = 'John'
u.last_name = 'Sander'
u.save()
r = Rower.objects.create(user=u)
r = Rower.objects.create(user=u,gdproptin=True,
gdproptindate=timezone.now()
)
res = add_workout_from_strokedata(u,1,data,strokedata,source='c2')
@@ -168,7 +174,10 @@ class StravaObjects(DjangoTestCase):
u.first_name = 'John'
u.last_name = 'Sander'
u.save()
r = Rower.objects.create(user=u)
r = Rower.objects.create(user=u,gdproptin=True,
gdproptindate=timezone.now()
)
res = add_workout_from_strokedata(u,1,workoutsummary,strokedata,
source='strava')
@@ -244,7 +253,9 @@ class StravaObjects(DjangoTestCase):
u.first_name = 'John'
u.last_name = 'Sander'
u.save()
r = Rower.objects.create(user=u)
r = Rower.objects.create(user=u,gdproptin=True,
gdproptindate=timezone.now()
)
res = add_workout_from_strokedata(u,1,workoutsummary,strokedata,
source='strava')
@@ -261,7 +272,10 @@ class STObjects(DjangoTestCase):
u = User.objects.create_user('john',
'sander@ds.ds',
'koeinsloot')
r = Rower.objects.create(user=u)
r = Rower.objects.create(user=u,gdproptin=True,
gdproptindate=timezone.now()
)
res = add_workout_from_stdata(u,1,data)
@@ -274,7 +288,11 @@ class STObjects(DjangoTestCase):
u = User.objects.create_user('john',
'sander@ds.ds',
'koeinsloot')
r = Rower.objects.create(user=u)
r = Rower.objects.create(user=u,gdproptin=True,
gdproptindate=timezone.now()
)
res = add_workout_from_stdata(u,1,data)
@@ -329,7 +347,10 @@ class EmailTests(TestCase):
u = User.objects.create_user('john',
'sander@ds.ds',
'koeinsloot')
r = Rower.objects.create(user=u)
r = Rower.objects.create(user=u,gdproptin=True,
gdproptindate=timezone.now()
)
nu = datetime.datetime.now()
workoutsbox = Mailbox.objects.create(name='workouts')
workoutsbox.save()
@@ -364,22 +385,21 @@ class EmailTests(TestCase):
class WorkoutTests(TestCase):
def setUp(self):
redis_connection.publish('tasks','KILL')
u = User.objects.create_user('john',
self.u = User.objects.create_user('john',
'sander@ds.ds',
'koeinsloot')
r = Rower.objects.create(user=u)
self.r = Rower.objects.create(user=self.u,gdproptin=True,
gdproptindate=timezone.now()
)
nu = datetime.datetime.now()
w = Workout.objects.create(name='testworkout',workouttype='On-water',
user=r,date=nu.strftime('%Y-%m-%d'),
self.w = Workout.objects.create(name='testworkout',
workouttype='On-water',
user=self.r,date=nu.strftime('%Y-%m-%d'),
starttime=nu.strftime('%H:%M:%S'),
duration="0:55:00",distance=8000)
def test_checkworkoutuser(self):
u = User.objects.get(username='john')
r = Rower.objects.get(user=u)
w = Workout.objects.get(user=r)
self.assertEqual(checkworkoutuser(u,w),True)
self.assertEqual(checkworkoutuser(self.u,self.w),True)
class C2Tests(TestCase):
def setUp(self):
@@ -387,7 +407,9 @@ class C2Tests(TestCase):
self.u = User.objects.create_user('john',
'sander@ds.ds',
'koeinsloot')
self.r = Rower.objects.create(user=u)
self.r = Rower.objects.create(user=self.u,gdproptin=True,
gdproptindate=timezone.now()
)
self.nu = datetime.datetime.now()
self.w = Workout.objects.create(name='testworkout',workouttype='On-water',
user=r,date=nu.strftime('%Y-%m-%d'),
@@ -405,7 +427,9 @@ class DataTest(TestCase):
u = User.objects.create_user('john',
'sander@ds.ds',
'koeinsloot')
r = Rower.objects.create(user=u)
r = Rower.objects.create(user=u,gdproptin=True,
gdproptindate=timezone.now()
)
self.nu = datetime.datetime.now()
@@ -586,7 +610,9 @@ class ViewTest(TestCase):
self.u = User.objects.create_user('john',
'sander@ds.ds',
'koeinsloot')
self.r = Rower.objects.create(user=self.u)
self.r = Rower.objects.create(user=self.u,gdproptin=True,
gdproptindate=timezone.now()
)
self.nu = datetime.datetime.now()
def test_upload_view_notloggedin(self):
+8 -16
View File
@@ -141,6 +141,8 @@ import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from rowers.emails import send_template_email
from pytz import timezone as tz,utc
import dateutil
import mpld3
@@ -954,23 +956,13 @@ def rower_register_view(request):
# Create and send email
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
subject = "Thank you for registering on rowsandall.com"
message = """
Thank you for registering on rowsandall.com. You can now login using the credentials you provided. The first thing you should do is go to the Settings page and make yourself familiar with the various options available to personalize your experience on the website. To get there, click the button with your first name on it in the upper right corner of the opening page.
from_address = 'Sander Roosendaal <info@rowsandall.com>'
As a minimum to get you started, enter your data in the Heart Rate Zones and Power Zones sections and your Functional Threshold Power. Then check your Account Information to make sure it is accurate and reflects your preferences.
For additional details on these settings and the buttons at the bottom of the page, read the settings tutorial at http://analytics.rowsandall.com/2017/11/02/rowsandall-settings-page-tutorial/.
Also check out our instructional videos at http://rowsandall.com/rowers/videos.
This website is a labor of love "by rowers, for rowers". If you find it to be useful, please help us cover our hosting costs and gain access to additional functionality by signing on as a Pro member: https://rowsandall.com/rowers/promembership
Oh, one more thing. The site is currently in beta and is developing fast. Bear with us. Don't hesitate to contact me at info@rowsandall.com if anything is broken or doesn't seem to work as advertised.
"""
send_mail(subject, message,
'Sander Roosendaal <info@rowsandall.com>',
[fullemail])
d = {'first_name':theuser.first_name}
send_template_email(from_address,[fullemail],
subject,'registeremail.html',d)
subject2 = "New User"
message2 = "New user registered.\n"
+1 -1
View File
@@ -94,7 +94,7 @@ MIDDLEWARE_CLASSES = [
'async_messages.middleware.AsyncMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'tz_detect.middleware.TimezoneMiddleware',
# 'rowers.middleware.GDPRMiddleWare',
'rowers.middleware.GDPRMiddleWare',
'rowers.middleware.PowerTimeFitnessMetricMiddleWare',
]