added emailbounced keyword to tasks
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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']
|
||||
|
||||
|
||||
186
rowers/tasks.py
186
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 <info@rowsandall.com>',
|
||||
[useremail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
return 1
|
||||
|
||||
@@ -340,7 +347,15 @@ def handle_sendemail_breakthrough(workoutid, useremail,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[useremail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
|
||||
# remove tcx file
|
||||
return 1
|
||||
@@ -380,7 +395,15 @@ def handle_sendemail_hard(workoutid, useremail,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[useremail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
|
||||
# remove tcx file
|
||||
return 1
|
||||
@@ -400,7 +423,14 @@ def handle_sendemail_userdeleted(name, email, debug=False, **kwargs):
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -426,7 +456,14 @@ def handle_sendemail_unrecognized(unrecognizedfile, useremail,
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
# remove tcx file
|
||||
try:
|
||||
@@ -464,7 +501,14 @@ def handle_sendemail_unrecognizedowner(useremail, userfirstname,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -486,7 +530,14 @@ def handle_sendemailtcx(first_name, last_name, email, tcxfile,**kwargs):
|
||||
|
||||
email.attach_file(tcxfile)
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
# remove tcx file
|
||||
os.remove(tcxfile)
|
||||
@@ -510,7 +561,16 @@ def handle_zip_file(emailfrom, subject, file,**kwargs):
|
||||
email.attach_file(file)
|
||||
if debug:
|
||||
print "attaching"
|
||||
res = email.send()
|
||||
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
if debug:
|
||||
print "sent"
|
||||
time.sleep(60)
|
||||
@@ -541,7 +601,14 @@ def handle_sendemailsummary(first_name, last_name, email, csvfile, **kwargs):
|
||||
email.attach_file(csvfile2)
|
||||
os.remove(csvfile2)
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
try:
|
||||
os.remove(csvfile)
|
||||
except:
|
||||
@@ -579,7 +646,14 @@ def handle_sendemailcsv(first_name, last_name, email, csvfile,**kwargs):
|
||||
os.remove(csvfile2)
|
||||
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -970,7 +1044,14 @@ def handle_sendemail_invite(email, name, code, teamname, manager,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1004,7 +1085,14 @@ def handle_sendemailnewresponse(first_name, last_name,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1034,7 +1122,14 @@ def handle_sendemailnewcomment(first_name,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1059,7 +1154,14 @@ def handle_sendemail_request(email, name, code, teamname, requestor, id,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1080,7 +1182,14 @@ def handle_sendemail_request_accept(email, name, teamname, managername,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1102,7 +1211,14 @@ def handle_sendemail_request_reject(email, name, teamname, managername,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1124,7 +1240,14 @@ def handle_sendemail_member_dropped(email, name, teamname, managername,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1147,7 +1270,14 @@ def handle_sendemail_team_removed(email, name, teamname, managername,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1169,7 +1299,14 @@ def handle_sendemail_invite_reject(email, name, teamname, managername,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1187,7 +1324,14 @@ def handle_sendemail_invite_accept(email, name, teamname, managername,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
res = email.send()
|
||||
if 'emailbounced' in kwargs:
|
||||
emailbounced = kwargs['emailbounced']
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
if not emailbounced:
|
||||
res = email.send()
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
@@ -105,7 +105,8 @@
|
||||
are limited to substantial changes in terms and conditions and other
|
||||
announcements impacting the terms on which you use the site. We will
|
||||
it is important to get these messages to you. If you do not with
|
||||
to receive such emails, you can indicate so in the user settings.
|
||||
to receive such emails, you can indicate so in the user settings ("Get
|
||||
Important Emails" under "Account Information").
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -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.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user