|
|
|
@@ -32,35 +32,6 @@ from django_rq import job
|
|
|
|
|
from django.utils import timezone
|
|
|
|
|
from django.utils.html import strip_tags
|
|
|
|
|
|
|
|
|
|
def textify(html):
|
|
|
|
|
# Remove html tags and continuous whitespaces
|
|
|
|
|
text_only = re.sub('[ \t]+', ' ', strip_tags(html))
|
|
|
|
|
# Strip single spaces in the beginning of each line
|
|
|
|
|
return text_only.replace('\n ', '\n').strip()
|
|
|
|
|
|
|
|
|
|
def send_template_email(from_email,to_email,subject,template,context,*args,**kwargs):
|
|
|
|
|
|
|
|
|
|
htmly = get_template(template)
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(context)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
from utils import deserialize_list
|
|
|
|
|
|
|
|
|
|
from rowers.dataprepnodjango import (
|
|
|
|
@@ -90,6 +61,51 @@ import arrow
|
|
|
|
|
|
|
|
|
|
from django.contrib.staticfiles import finders
|
|
|
|
|
|
|
|
|
|
def textify(html):
|
|
|
|
|
# Remove html tags and continuous whitespaces
|
|
|
|
|
text_only = re.sub('[ \t]+', ' ', strip_tags(html))
|
|
|
|
|
# Strip single spaces in the beginning of each line
|
|
|
|
|
return text_only.replace('\n ', '\n').strip()
|
|
|
|
|
|
|
|
|
|
def send_template_email(from_email,to_email,subject,
|
|
|
|
|
template,context,
|
|
|
|
|
*args,**kwargs):
|
|
|
|
|
|
|
|
|
|
htmly = get_template(template)
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(context)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
|
|
|
|
|
if 'attach_file' in kwargs:
|
|
|
|
|
fileobj = kwargs['attach_file']
|
|
|
|
|
if os.path.isfile(fileobj):
|
|
|
|
|
msg.attach_file(fileobj)
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
fileobj2 = fileobj
|
|
|
|
|
with gzip.open(fileobj+'.gz','rb') as f_in, open(fileobj2,'wb') as f_out:
|
|
|
|
|
shutil.copyfileobj(f_in,f_out)
|
|
|
|
|
msg.attach_file(fileobj2)
|
|
|
|
|
os.remove(fileobj2)
|
|
|
|
|
except IOError:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.task
|
|
|
|
|
def add(x, y):
|
|
|
|
|
return x + y
|
|
|
|
@@ -357,8 +373,6 @@ def handle_sendemail_breakthrough(workoutid, useremail,
|
|
|
|
|
subject = "A breakthrough workout on rowsandall.com"
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
htmly = get_template('breakthroughemail.html')
|
|
|
|
|
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':userfirstname,
|
|
|
|
|
'siteurl':siteurl,
|
|
|
|
@@ -366,23 +380,13 @@ def handle_sendemail_breakthrough(workoutid, useremail,
|
|
|
|
|
'btvalues':tablevalues,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(d)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [useremail])
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = send_template_email(from_email,[useremail],
|
|
|
|
|
subject,'breakthroughemail.html',
|
|
|
|
|
d,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# remove tcx file
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
# send email when a breakthrough workout is uploaded
|
|
|
|
@@ -403,12 +407,20 @@ def handle_sendemail_hard(workoutid, useremail,
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
btvalues = pd.read_json(btvalues)
|
|
|
|
|
btvalues.sort_values('delta', axis=0, inplace=True)
|
|
|
|
|
|
|
|
|
|
tablevalues = [
|
|
|
|
|
{'delta': t.delta,
|
|
|
|
|
'cpvalue': t.cpvalues,
|
|
|
|
|
'pwr': t.pwr
|
|
|
|
|
} for t in btvalues.itertuples()
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# send email with attachment
|
|
|
|
|
subject = "That was a pretty hard workout on rowsandall.com"
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
htmly = get_template('hardemail.html')
|
|
|
|
|
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':userfirstname,
|
|
|
|
|
'siteurl':siteurl,
|
|
|
|
@@ -416,24 +428,10 @@ def handle_sendemail_hard(workoutid, useremail,
|
|
|
|
|
'btvalues':tablevalues,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(d)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [useremail])
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
res = send_template_email(from_email,[useremail],
|
|
|
|
|
subject,'hardemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# remove tcx file
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -511,27 +509,15 @@ def handle_sendemail_unrecognizedowner(useremail, userfirstname,
|
|
|
|
|
fullemail = useremail
|
|
|
|
|
subject = "Unrecognized file from Rowsandall.com"
|
|
|
|
|
|
|
|
|
|
plaintext = get_template('csvemail.txt')
|
|
|
|
|
htmly = get_template('csvemail.html')
|
|
|
|
|
htmly = get_template('unrecognizedemail.html')
|
|
|
|
|
|
|
|
|
|
d = {'first_name':first_name}
|
|
|
|
|
d = {'first_name':userfirstname}
|
|
|
|
|
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(d)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
|
|
|
|
|
res = send_template_email(from_email,[fullemail],
|
|
|
|
|
subject,'csvemail.html',d,
|
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
@@ -550,24 +536,11 @@ def handle_sendemailtcx(first_name, last_name, email, tcxfile,**kwargs):
|
|
|
|
|
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(d)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
res = send_template_email(from_email,[fullemail],
|
|
|
|
|
subject,'tcxemail.html',d,
|
|
|
|
|
attach_file=tcxfile,**kwargs)
|
|
|
|
|
|
|
|
|
|
msg.attach_file(tcxfile)
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# remove tcx file
|
|
|
|
|
os.remove(tcxfile)
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
@@ -612,30 +585,10 @@ def handle_sendemailsummary(first_name, last_name, email, csvfile, **kwargs):
|
|
|
|
|
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(d)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if os.path.isfile(csvfile):
|
|
|
|
|
msg.attach_file(csvfile)
|
|
|
|
|
else:
|
|
|
|
|
csvfile2 = csvfile
|
|
|
|
|
with gzip.open(csvfile + '.gz', 'rb') as f_in, open(csvfile2, 'wb') as f_out:
|
|
|
|
|
shutil.copyfileobj(f_in, f_out)
|
|
|
|
|
|
|
|
|
|
msg.attach_file(csvfile2)
|
|
|
|
|
os.remove(csvfile2)
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
res = send_template_email(from_email,[fullemail],
|
|
|
|
|
subject,'summarymail.html',d,
|
|
|
|
|
attach_file=csvfile,
|
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
os.remove(csvfile)
|
|
|
|
@@ -654,36 +607,14 @@ def handle_sendemailcsv(first_name, last_name, email, csvfile,**kwargs):
|
|
|
|
|
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
|
|
|
|
|
subject = "File from Rowsandall.com"
|
|
|
|
|
|
|
|
|
|
htmly = get_template('csvemail.html')
|
|
|
|
|
|
|
|
|
|
d = {'first_name':first_name}
|
|
|
|
|
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(d)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
|
|
|
|
|
if os.path.isfile(csvfile):
|
|
|
|
|
msg.attach_file(csvfile)
|
|
|
|
|
else:
|
|
|
|
|
csvfile2 = csvfile
|
|
|
|
|
with gzip.open(csvfile + '.gz', 'rb') as f_in, open(csvfile2, 'wb') as f_out:
|
|
|
|
|
shutil.copyfileobj(f_in, f_out)
|
|
|
|
|
|
|
|
|
|
msg.attach_file(csvfile2)
|
|
|
|
|
os.remove(csvfile2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
res = send_template_email(from_email,[fullemail],
|
|
|
|
|
subject,'csvemail.html',d,
|
|
|
|
|
attach_file=csvfile,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
@@ -819,22 +750,9 @@ def handle_otwsetpower(self,f1, boattype, weightvalue,
|
|
|
|
|
'workoutid':workoutid,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(d)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = handle_template_email(from_email,[fullemail],
|
|
|
|
|
subject,'otwpoweremail.html',d,
|
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
@@ -1062,29 +980,19 @@ def handle_sendemail_invite(email, name, code, teamname, manager,
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
htmly = get_template('teaminviteemail.html')
|
|
|
|
|
|
|
|
|
|
d = {
|
|
|
|
|
'name':name,
|
|
|
|
|
'manage':manager,
|
|
|
|
|
'manager':manager,
|
|
|
|
|
'code':code,
|
|
|
|
|
'teamname':teamname,
|
|
|
|
|
'siteurl':siteurl
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html_content = htmly.render(d)
|
|
|
|
|
text_content = textify(html_content)
|
|
|
|
|
|
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = msg.send()
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
res = send_template_email(from_email,[fullemail],
|
|
|
|
|
subject,'teaminviteemail.html',d,
|
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
@@ -1106,8 +1014,6 @@ def handle_sendemailnewresponse(first_name, last_name,
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
htmly = get_template('teamresponseemail.html')
|
|
|
|
|
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':first_name,
|
|
|
|
|
'commenter_first_name':commenter_first_name,
|
|
|
|
@@ -1133,29 +1039,31 @@ def handle_sendemailnewcomment(first_name,
|
|
|
|
|
comment, workoutname,
|
|
|
|
|
workoutid,
|
|
|
|
|
debug=False,**kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fullemail = first_name + ' ' + last_name + ' <' + email + '>'
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
subject = 'New comment on workout ' + workoutname
|
|
|
|
|
message = 'Dear ' + first_name + ',\n\n'
|
|
|
|
|
message += commenter_first_name + ' ' + commenter_last_name
|
|
|
|
|
message += ' has written a new comment on your workout '
|
|
|
|
|
message += workoutname + '\n\n'
|
|
|
|
|
message += comment
|
|
|
|
|
message += '\n\n'
|
|
|
|
|
message += 'You can read the comment here:\n'
|
|
|
|
|
message += 'https://rowsandall.com/rowers/workout/' + \
|
|
|
|
|
str(workoutid) + '/comment'
|
|
|
|
|
|
|
|
|
|
email = EmailMessage(subject, message,
|
|
|
|
|
'Rowsandall <info@rowsandall.com>',
|
|
|
|
|
[fullemail])
|
|
|
|
|
siteurl = SITE_URL
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = email.send()
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':first_name,
|
|
|
|
|
'commenter_first_name':commenter_first_name,
|
|
|
|
|
'commenter_last_name':commenter_last_name,
|
|
|
|
|
'comment':comment,
|
|
|
|
|
'workoutname':workoutname,
|
|
|
|
|
'siteurl':siteurl,
|
|
|
|
|
'workoutid':workoutid,
|
|
|
|
|
'commentid':commentid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res = send_template_email(from_email,[fullemail],subject,
|
|
|
|
|
'teamresponseemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
@@ -1166,28 +1074,22 @@ def handle_sendemail_request(email, name, code, teamname, requestor, id,
|
|
|
|
|
debug=False,**kwargs):
|
|
|
|
|
fullemail = name + ' <' + email + '>'
|
|
|
|
|
subject = 'Request to join team ' + teamname
|
|
|
|
|
message = 'Dear ' + name + ',\n\n'
|
|
|
|
|
message += requestor + ' is requesting admission to your team ' + teamname
|
|
|
|
|
message += ' on rowsandall.com\n\n'
|
|
|
|
|
message += 'Click the direct link to accept: \n'
|
|
|
|
|
message += 'https://rowsandall.com/rowers/me/request/' + code + ' \n\n'
|
|
|
|
|
message += 'Click the following link to reject the request: \n'
|
|
|
|
|
message += 'https://rowsandall.com/rowers/me/request/' + str(id) + ' \n\n'
|
|
|
|
|
message += 'You can find all pending requests on your team management page:\n'
|
|
|
|
|
message += 'https://rowsandall.com/rowers/me/teams\n\n'
|
|
|
|
|
message += "Best Regards, the Rowsandall Team"
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
email = EmailMessage(subject, message,
|
|
|
|
|
'Rowsandall <info@rowsandall.com>',
|
|
|
|
|
[fullemail])
|
|
|
|
|
siteurl = SITE_URL
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
d = {
|
|
|
|
|
'requestor':requestor,
|
|
|
|
|
'teamname':teamname,
|
|
|
|
|
'siteurl':siteurl,
|
|
|
|
|
'id':id,
|
|
|
|
|
'first_name':name,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = email.send()
|
|
|
|
|
res = send_template_email(from_email,[fullemail],subject,
|
|
|
|
|
'teamrequestemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
@@ -1198,24 +1100,19 @@ def handle_sendemail_request_accept(email, name, teamname, managername,
|
|
|
|
|
debug=False,**kwargs):
|
|
|
|
|
fullemail = name + ' <' + email + '>'
|
|
|
|
|
subject = 'Welcome to ' + teamname
|
|
|
|
|
message = 'Dear ' + name + ',\n\n'
|
|
|
|
|
message += managername
|
|
|
|
|
message += ' has accepted your request to be part of the team '
|
|
|
|
|
message += teamname
|
|
|
|
|
message += '\n\n'
|
|
|
|
|
message += "Best Regards, the Rowsandall Team"
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
email = EmailMessage(subject, message,
|
|
|
|
|
'Rowsandall <info@rowsandall.com>',
|
|
|
|
|
[fullemail])
|
|
|
|
|
siteurl = SITE_URL
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = email.send()
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':name,
|
|
|
|
|
'managername':managername,
|
|
|
|
|
'teamname':teamname,
|
|
|
|
|
}
|
|
|
|
|
res = send_template_email(from_email,[fullemail],subject,
|
|
|
|
|
'teamwelcomeemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
@@ -1226,26 +1123,19 @@ def handle_sendemail_request_reject(email, name, teamname, managername,
|
|
|
|
|
debug=False,**kwargs):
|
|
|
|
|
fullemail = name + ' <' + email + '>'
|
|
|
|
|
subject = 'Your application to ' + teamname + ' was rejected'
|
|
|
|
|
message = 'Dear ' + name + ',\n\n'
|
|
|
|
|
message += 'Unfortunately, '
|
|
|
|
|
message += managername
|
|
|
|
|
message += ' has rejected your request to be part of the team '
|
|
|
|
|
message += teamname
|
|
|
|
|
message += '\n\n'
|
|
|
|
|
message += "Best Regards, the Rowsandall Team"
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
email = EmailMessage(subject, message,
|
|
|
|
|
'Rowsandall <info@rowsandall.com>',
|
|
|
|
|
[fullemail])
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = email.send()
|
|
|
|
|
siteurl = SITE_URL
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':name,
|
|
|
|
|
'managername':managername,
|
|
|
|
|
'teamname':teamname,
|
|
|
|
|
}
|
|
|
|
|
res = send_template_email(from_email,[fullemail],subject,
|
|
|
|
|
'teamrejectemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
@@ -1255,25 +1145,19 @@ def handle_sendemail_member_dropped(email, name, teamname, managername,
|
|
|
|
|
debug=False,**kwargs):
|
|
|
|
|
fullemail = name + ' <' + email + '>'
|
|
|
|
|
subject = 'You were removed from ' + teamname
|
|
|
|
|
message = 'Dear ' + name + ',\n\n'
|
|
|
|
|
message += 'Unfortunately, '
|
|
|
|
|
message += managername
|
|
|
|
|
message += ' has removed you from the team '
|
|
|
|
|
message += teamname
|
|
|
|
|
message += '\n\n'
|
|
|
|
|
message += "Best Regards, the Rowsandall Team"
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
email = EmailMessage(subject, message,
|
|
|
|
|
'Rowsandall <info@rowsandall.com>',
|
|
|
|
|
[fullemail])
|
|
|
|
|
siteurl = SITE_URL
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = email.send()
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':name,
|
|
|
|
|
'managername':managername,
|
|
|
|
|
'teamname':teamname,
|
|
|
|
|
}
|
|
|
|
|
res = send_template_email(from_email,[fullemail],subject,
|
|
|
|
|
'teamdropemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
@@ -1282,28 +1166,22 @@ def handle_sendemail_member_dropped(email, name, teamname, managername,
|
|
|
|
|
@app.task
|
|
|
|
|
def handle_sendemail_team_removed(email, name, teamname, managername,
|
|
|
|
|
debug=False,**kwargs):
|
|
|
|
|
|
|
|
|
|
fullemail = name + ' <' + email + '>'
|
|
|
|
|
subject = 'Team ' + teamname + ' was deleted'
|
|
|
|
|
message = 'Dear ' + name + ',\n\n'
|
|
|
|
|
message += managername
|
|
|
|
|
message += ' has decided to delete the team '
|
|
|
|
|
message += teamname
|
|
|
|
|
message += '\n\n'
|
|
|
|
|
message += 'The ' + teamname + ' tag has been removed from all your '
|
|
|
|
|
message += 'workouts on rowsandall.com.\n\n'
|
|
|
|
|
message += "Best Regards, the Rowsandall Team"
|
|
|
|
|
subject = 'You were removed from ' + teamname
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
email = EmailMessage(subject, message,
|
|
|
|
|
'Rowsandall <info@rowsandall.com>',
|
|
|
|
|
[fullemail])
|
|
|
|
|
siteurl = SITE_URL
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = email.send()
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':name,
|
|
|
|
|
'managername':managername,
|
|
|
|
|
'teamname':teamname,
|
|
|
|
|
}
|
|
|
|
|
res = send_template_email(from_email,[fullemail],subject,
|
|
|
|
|
'teamremoveemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
@@ -1314,26 +1192,20 @@ def handle_sendemail_invite_reject(email, name, teamname, managername,
|
|
|
|
|
debug=False,**kwargs):
|
|
|
|
|
fullemail = managername + ' <' + email + '>'
|
|
|
|
|
subject = 'Your invitation to ' + name + ' was rejected'
|
|
|
|
|
message = 'Dear ' + managername + ',\n\n'
|
|
|
|
|
message += 'Unfortunately, '
|
|
|
|
|
message += name
|
|
|
|
|
message += ' has rejected your invitation to be part of the team '
|
|
|
|
|
message += teamname
|
|
|
|
|
message += '\n\n'
|
|
|
|
|
message += "Best Regards, the Rowsandall Team"
|
|
|
|
|
|
|
|
|
|
email = EmailMessage(subject, message,
|
|
|
|
|
'Rowsandall <info@rowsandall.com>',
|
|
|
|
|
[fullemail])
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = email.send()
|
|
|
|
|
siteurl = SITE_URL
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':name,
|
|
|
|
|
'managername':managername,
|
|
|
|
|
'teamname':teamname,
|
|
|
|
|
}
|
|
|
|
|
res = send_template_email(from_email,[fullemail],subject,
|
|
|
|
|
'teaminviterejectemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
@@ -1343,21 +1215,20 @@ def handle_sendemail_invite_accept(email, name, teamname, managername,
|
|
|
|
|
debug=False,**kwargs):
|
|
|
|
|
fullemail = managername + ' <' + email + '>'
|
|
|
|
|
subject = 'Your invitation to ' + name + ' was accepted'
|
|
|
|
|
message = 'Dear ' + managername + ',\n\n'
|
|
|
|
|
message += name + ' has accepted your invitation to be part of the team ' + teamname + '\n\n'
|
|
|
|
|
message += "Best Regards, the Rowsandall Team"
|
|
|
|
|
|
|
|
|
|
email = EmailMessage(subject, message,
|
|
|
|
|
'Rowsandall <info@rowsandall.com>',
|
|
|
|
|
[fullemail])
|
|
|
|
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
|
|
|
|
|
|
|
|
|
if 'emailbounced' in kwargs:
|
|
|
|
|
emailbounced = kwargs['emailbounced']
|
|
|
|
|
else:
|
|
|
|
|
emailbounced = False
|
|
|
|
|
siteurl = SITE_URL
|
|
|
|
|
if debug:
|
|
|
|
|
siteurl = SITE_URL_DEV
|
|
|
|
|
|
|
|
|
|
if not emailbounced:
|
|
|
|
|
res = email.send()
|
|
|
|
|
d = {
|
|
|
|
|
'first_name':name,
|
|
|
|
|
'managername':managername,
|
|
|
|
|
'teamname':teamname,
|
|
|
|
|
}
|
|
|
|
|
res = send_template_email(from_email,[fullemail],subject,
|
|
|
|
|
'teaminviteacceptemail.html',d,**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|