diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py
index 87895291..4a082f35 100644
--- a/rowers/c2stuff.py
+++ b/rowers/c2stuff.py
@@ -18,6 +18,7 @@ from iso8601 import ParseError
import numpy
import json
+from json.decoder import JSONDecodeError
from rowsandall_app.settings import (
C2_CLIENT_ID, C2_REDIRECT_URI, C2_CLIENT_SECRET
diff --git a/rowers/templates/plantrialwelcome.html b/rowers/templates/plantrialwelcome.html
new file mode 100644
index 00000000..9da3e750
--- /dev/null
+++ b/rowers/templates/plantrialwelcome.html
@@ -0,0 +1,26 @@
+{% extends "emailbase.html" %}
+
+{% block body %}
+
Dear {{ first_name }},
+
+
+ Welcome on the trial for the Self-Coach plan.
+
+
+As the developer of the Rowsandall.com site I am very interested to know what you think of Rowsandall.com. Especially, I'd like to understand how you started using the site, what you are looking for, and what you think could be improved.
+
+
+The Self-Coach functionality allows you to create training plans and sessions for you and your training group. Feel free to contact me any time you need help.
+
+
+I'd also love to hear a bit about your rowing background.
+
+
+Thank you very much for your help and for supporting rowsandall.com.
+
+
+
+
+ Best Regards, the Rowsandall Team
+
+{% endblock %}
diff --git a/rowers/templates/protrialewelcome.html b/rowers/templates/protrialewelcome.html
new file mode 100644
index 00000000..b2e6d88a
--- /dev/null
+++ b/rowers/templates/protrialewelcome.html
@@ -0,0 +1,26 @@
+{% extends "emailbase.html" %}
+
+{% block body %}
+Dear {{ first_name }},
+
+
+ Welcome on the trial for the Pro plan.
+
+
+As the developer of the Rowsandall.com site I am very interested to know what you think of Rowsandall.com. Especially, I'd like to understand how you started using the site, what you are looking for, and what you think could be improved.
+
+
+The Self-Coach functionality allows you to create training plans and sessions for you and your training group. Feel free to contact me any time you need help.
+
+
+I'd also love to hear a bit about your rowing background.
+
+
+Thank you very much for your help and for supporting rowsandall.com.
+
+
+
+
+ Best Regards, the Rowsandall Team
+
+{% endblock %}
diff --git a/rowers/views/userviews.py b/rowers/views/userviews.py
index a8aea814..710fd771 100644
--- a/rowers/views/userviews.py
+++ b/rowers/views/userviews.py
@@ -13,23 +13,30 @@ def start_trial_view(request):
messages.error(request,'You do not qualify for a trial')
url = '/rowers/paidplans'
return HttpResponseRedirect(url)
-
+
r.protrialexpires = datetime.date.today()+datetime.timedelta(13)
r.save()
url = reverse('workouts_view')
messages.info(request,'We have started your 14 day trial period')
-
+
subject2 = "User started Pro Trial"
message2 = "User Started Pro Trial.\n"
message2 += request.user.email + "\n"
message2 += "User name: "+request.user.username
-
+
send_mail(subject2, message2,
'Rowsandall Server ',
['roosendaalsander@gmail.com'])
-
+
+ send_template_email('Rowsandall ',
+ [r.user.email],
+ 'Welcome to the Rowsandall Pro Trial',
+ 'protrialewelcome.html',
+ {'first_name':r.user.first_name,
+ 'last_name':r.user.last_name})
+
return HttpResponseRedirect(url)
@login_required()
@@ -40,7 +47,7 @@ def start_plantrial_view(request):
messages.error(request,'You do not qualify for a trial')
url = '/rowers/paidplans'
return HttpResponseRedirect(url)
-
+
r.plantrialexpires = datetime.date.today()+datetime.timedelta(13)
r.protrialexpires = datetime.date.today()+datetime.timedelta(13)
r.save()
@@ -48,16 +55,23 @@ def start_plantrial_view(request):
url = reverse('workouts_view')
messages.info(request,'We have started your 14 day trial period')
-
+
subject2 = "User started Plan Trial"
message2 = "User Started Plan Trial.\n"
message2 += request.user.email + "\n"
message2 += "User name: "+request.user.username
-
+
send_mail(subject2, message2,
'Rowsandall Server ',
['roosendaalsander@gmail.com'])
-
+
+ send_template_email('Rowsandall ',
+ [r.user.email],
+ 'Welcome to the Rowsandall Self-Coach Trial',
+ 'plantrialwelcome.html',
+ {'first_name':r.user.first_name,
+ 'last_name':r.user.last_name})
+
return HttpResponseRedirect(url)
# Page where user can manage his favorite charts
@@ -79,7 +93,7 @@ def rower_favoritecharts_view(request,userid=0):
FavoriteChartFormSet = formset_factory(FavoriteForm,formset=BaseFavoriteFormSet,extra=0)
if aantal==0:
FavoriteChartFormSet = formset_factory(FavoriteForm,formset=BaseFavoriteFormSet,extra=1)
-
+
if request.method == 'POST':
favorites_formset = FavoriteChartFormSet(request.POST)
@@ -115,7 +129,7 @@ def rower_favoritecharts_view(request,userid=0):
messages.error(request,message)
else:
favorites_formset = FavoriteChartFormSet(initial=favorites_data)
-
+
context = {
'favorites_formset':favorites_formset,
@@ -123,8 +137,8 @@ def rower_favoritecharts_view(request,userid=0):
'rower':r,
}
-
-
+
+
return render(request,'favoritecharts.html',context)
# page where user sets his export settings
@@ -154,7 +168,7 @@ def rower_exportsettings_view(request,userid=0):
'name': 'Export Settings'
}
]
-
+
return render(request, 'rower_exportsettings.html',
{'form':form,
'rower':r,
@@ -367,7 +381,7 @@ def rower_prefs_view(request,userid=0,message=""):
'rower':r,
})
-
+
# Revoke an app that you granted access through the API.
# this views is called when you press a button on the User edit page
# the button is only there when you have granted access to an app
@@ -401,7 +415,7 @@ def rower_update_empower_view(
r = getrower(request.user)
except Rower.DoesNotExist:
raise Http404("Rower doesn't exist")
-
+
if request.method == 'POST' and 'daterange' in request.POST:
dateform = DateRangeForm(request.POST)
if dateform.is_valid():
@@ -416,7 +430,7 @@ def rower_update_empower_view(
'startdate':startdate,
'enddate':enddate,
})
-
+
if request.method == 'POST' and 'workouts' in request.POST:
form = WorkoutMultipleCompareForm(request.POST)
@@ -424,7 +438,7 @@ def rower_update_empower_view(
cd = form.cleaned_data
workouts = cd['workouts']
workoutdicts = []
-
+
for w in workouts:
if w.user != r:
message = "You can only alter your own workouts"
@@ -440,7 +454,7 @@ def rower_update_empower_view(
messages.error(request,message)
else:
-
+
workoutdict = {
'id':w.id,
'boattype':w.boattype,
@@ -454,7 +468,7 @@ def rower_update_empower_view(
w.workoutsource = 'speedcoach2corrected'
w.save()
-
+
job = myqueue(queuelow,handle_update_empower,
request.user.email,workoutdicts,
debug=False,
@@ -479,7 +493,7 @@ def rower_update_empower_view(
workoutsource='speedcoach2',
user=r,
).order_by("-date","-starttime")
-
+
form = WorkoutMultipleCompareForm()
form.fields["workouts"].queryset = workouts
# GET request = prepare form
@@ -491,5 +505,3 @@ def rower_update_empower_view(
'form':form,
'rower':r
})
-
-