diff --git a/rowers/dataprep.py b/rowers/dataprep.py
index 24746f04..cd983a7b 100644
--- a/rowers/dataprep.py
+++ b/rowers/dataprep.py
@@ -1048,7 +1048,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
powermean = df['power'].mean()
except KeyError:
powermean = 0
-
+
if powermean != 0:
thesecs = totaltime
maxt = 1.05 * thesecs
@@ -1071,45 +1071,27 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
# submit email task to send email about breakthrough workout
if isbreakthrough:
a_messages.info(
- r.user, 'It looks like you have a new breakthrough workout')
- if settings.DEBUG and r.getemailnotifications:
- res = handle_sendemail_breakthrough.delay(w.id, r.user.email,
- r.user.first_name,
- r.user.last_name,
- btvalues=btvalues.to_json())
- elif r.getemailnotifications:
- try:
- res = queuehigh.enqueue(
- handle_sendemail_breakthrough(w.id,
- r.user.email,
- r.user.first_name,
- r.user.last_name,
- btvalues=btvalues.to_json()))
- except AttributeError:
- pass
- else:
- pass
+ r.user, 'It looks like you have a new breakthrough workout'
+ )
+ if r.getemailnotifications and not r.emailbounced:
+ job = myqueue(queuehigh,handle_sendemail_breakthrough,
+ w.id,
+ r.user.email,
+ r.user.first_name,
+ r.user.last_name,
+ btvalues=btvalues.to_json())
+
# submit email task to send email about breakthrough workout
if ishard:
a_messages.info(r.user, 'That was a pretty hard workout')
- if settings.DEBUG and r.getemailnotifications:
- res = handle_sendemail_hard.delay(w.id, r.user.email,
- r.user.first_name,
- r.user.last_name,
- btvalues=btvalues.to_json())
- elif r.getemailnotifications:
- try:
- res = queuehigh.enqueue(
- handle_sendemail_hard(w.id,
- r.user.email,
- r.user.first_name,
- r.user.last_name,
- btvalues=btvalues.to_json()))
- except AttributeError:
- pass
- else:
- pass
-
+ if r.getemailnotifications and not r.emailbounced:
+ job = myqueue(queuehigh,handle_sendemail_hard,
+ w.id,
+ r.user.email,
+ r.user.first_name,
+ r.user.last_name,
+ btvalues=btvalues.to_json())
+
return (w.id, message)
diff --git a/rowers/models.py b/rowers/models.py
index c5afa452..5ec4a937 100644
--- a/rowers/models.py
+++ b/rowers/models.py
@@ -574,6 +574,9 @@ class Rower(models.Model):
emailbounced = models.BooleanField(default=False,
verbose_name='Email Address Bounced')
+ getimportantemails = models.BooleanField(default=True,
+ verbose_name='Get Important Emails')
+
rowerplan = models.CharField(default='basic',max_length=30,
choices=plans)
@@ -1586,7 +1589,9 @@ class RowerPowerZonesForm(ModelForm):
class AccountRowerForm(ModelForm):
class Meta:
model = Rower
- fields = ['sex','birthdate','weightcategory','getemailnotifications',
+ fields = ['sex','birthdate','weightcategory',
+ 'getemailnotifications',
+ 'getimportantemails',
'defaulttimezone','showfavoritechartnotes',
'defaultlandingpage']
diff --git a/rowers/tasks.py b/rowers/tasks.py
index ebac2355..42568a6e 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -253,7 +253,7 @@ def handle_new_workout_from_file(r, f2,
@app.task
-def handle_updatedps(useremail, workoutids, debug=False):
+def handle_updatedps(useremail, workoutids, debug=False,**kwargs):
for wid, f1 in workoutids:
havedata = 1
try:
@@ -270,6 +270,7 @@ def handle_updatedps(useremail, workoutids, debug=False):
if havedata:
update_strokedata(wid, rowdata.df, debug=debug)
+
subject = "Rowsandall.com Your Distance per Stroke metric has been updated"
message = "All your workouts now have Distance per Stroke"
@@ -277,7 +278,13 @@ def handle_updatedps(useremail, workoutids, debug=False):
'Rowsandall
diff --git a/rowers/views.py b/rowers/views.py index 69efcd63..67938eb2 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -1708,7 +1708,18 @@ def workout_tcxemail_view(request,id=0): r = getrower(request.user) w = get_workout(id) if (checkworkoutuser(request.user,w)): - tcxfile,tcxmessg = stravastuff.createstravaworkoutdata(w,dozip=False) + if r.emailbounced: + message = "Please check your email address first. Email to this address bounced." + messages.error(request, message) + return HttpResponseRedirect( + reverse(workout_export_view, + kwargs = { + 'id':str(w.id), + }) + ) + + + tcxfile,tcxmessg = stravastuff.createstravaworkoutdata(w,dozip=False) if tcxfile == 0: message = "Something went wrong (TCX export) "+tcxmessg messages.error(request,message) @@ -1726,11 +1737,12 @@ def workout_tcxemail_view(request,id=0): successmessage = "The TCX file was sent to you per email" messages.info(request,successmessage) - url = reverse(workout_export_view, - kwargs = { - 'id':str(w.id), - }) + + url = reverse(workout_export_view, + kwargs = { + 'id':str(w.id), + }) response = HttpResponseRedirect(url) else: @@ -1750,6 +1762,16 @@ def workout_gpxemail_view(request,id=0): message = "" successmessage = "" r = Rower.objects.get(user=request.user) + if r.emailbounced: + message = "Please check your email address first. Email to this address bounced." + messages.error(request, message) + return HttpResponseRedirect( + reverse(workout_export_view, + kwargs = { + 'id':str(w.id), + }) + ) + w = get_workout(id) if (checkworkoutuser(request.user,w)): @@ -1787,6 +1809,15 @@ def workout_gpxemail_view(request,id=0): @login_required() def workouts_summaries_email_view(request): r = getrower(request.user) + if r.emailbounced: + message = "Please check your email address first. Email to this address bounced." + messages.error(request, message) + return HttpResponseRedirect( + reverse(workout_export_view, + kwargs = { + 'id':str(w.id), + }) + ) if request.method == 'POST': form = DateRangeForm(request.POST) @@ -1819,6 +1850,16 @@ def workouts_summaries_email_view(request): def workout_csvemail_view(request,id=0): message = "" r = getrower(request.user) + if r.emailbounced: + message = "Please check your email address first. Email to this address bounced." + messages.error(request, message) + return HttpResponseRedirect( + reverse(workout_export_view, + kwargs = { + 'id':str(w.id), + }) + ) + w = get_workout(id) if (checkworkoutuser(request.user,w)): @@ -11229,6 +11270,7 @@ def rower_edit_view(request,rowerid=0,message=""): birthdate = cd['birthdate'] showfavoritechartnotes = cd['showfavoritechartnotes'] getemailnotifications = cd['getemailnotifications'] + getimportantemails = cd['getimportantemails'] defaulttimezone=cd['defaulttimezone'] u = r.user if u.email != email and len(email): @@ -11247,6 +11289,7 @@ def rower_edit_view(request,rowerid=0,message=""): r.defaulttimezone=defaulttimezone r.weightcategory = weightcategory r.getemailnotifications = getemailnotifications + r.getimportantemails = getimportantemails r.defaultlandingpage = defaultlandingpage r.showfavoritechartnotes = showfavoritechartnotes r.sex = sex @@ -11587,7 +11630,8 @@ def rower_calcdps_view(request): r = getrower(request.user) ws = [(w.id,w.csvfilename) for w in Workout.objects.filter(user=r)] - res = myqueue(queue,handle_updatedps,r.user.email,ws,debug=False) + res = myqueue(queue,handle_updatedps,r.user.email,ws,debug=False, + emailbounced=r.emailbounced) messages.info(request,"Your workouts are being updated in the background. You will receive email when this is done.")