a few more templates
This commit is contained in:
501
rowers/tasks.py
501
rowers/tasks.py
@@ -32,35 +32,6 @@ from django_rq import job
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.html import strip_tags
|
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 utils import deserialize_list
|
||||||
|
|
||||||
from rowers.dataprepnodjango import (
|
from rowers.dataprepnodjango import (
|
||||||
@@ -90,6 +61,51 @@ import arrow
|
|||||||
|
|
||||||
from django.contrib.staticfiles import finders
|
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
|
@app.task
|
||||||
def add(x, y):
|
def add(x, y):
|
||||||
return x + y
|
return x + y
|
||||||
@@ -357,8 +373,6 @@ def handle_sendemail_breakthrough(workoutid, useremail,
|
|||||||
subject = "A breakthrough workout on rowsandall.com"
|
subject = "A breakthrough workout on rowsandall.com"
|
||||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
|
|
||||||
htmly = get_template('breakthroughemail.html')
|
|
||||||
|
|
||||||
d = {
|
d = {
|
||||||
'first_name':userfirstname,
|
'first_name':userfirstname,
|
||||||
'siteurl':siteurl,
|
'siteurl':siteurl,
|
||||||
@@ -366,23 +380,13 @@ def handle_sendemail_breakthrough(workoutid, useremail,
|
|||||||
'btvalues':tablevalues,
|
'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
|
return 1
|
||||||
|
|
||||||
# send email when a breakthrough workout is uploaded
|
# send email when a breakthrough workout is uploaded
|
||||||
@@ -403,12 +407,20 @@ def handle_sendemail_hard(workoutid, useremail,
|
|||||||
if debug:
|
if debug:
|
||||||
siteurl = SITE_URL_DEV
|
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
|
# send email with attachment
|
||||||
subject = "That was a pretty hard workout on rowsandall.com"
|
subject = "That was a pretty hard workout on rowsandall.com"
|
||||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
|
|
||||||
htmly = get_template('hardemail.html')
|
|
||||||
|
|
||||||
d = {
|
d = {
|
||||||
'first_name':userfirstname,
|
'first_name':userfirstname,
|
||||||
'siteurl':siteurl,
|
'siteurl':siteurl,
|
||||||
@@ -416,24 +428,10 @@ def handle_sendemail_hard(workoutid, useremail,
|
|||||||
'btvalues':tablevalues,
|
'btvalues':tablevalues,
|
||||||
}
|
}
|
||||||
|
|
||||||
html_content = htmly.render(d)
|
res = send_template_email(from_email,[useremail],
|
||||||
text_content = textify(html_content)
|
subject,'hardemail.html',d,**kwargs)
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# remove tcx file
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
@@ -511,27 +509,15 @@ def handle_sendemail_unrecognizedowner(useremail, userfirstname,
|
|||||||
fullemail = useremail
|
fullemail = useremail
|
||||||
subject = "Unrecognized file from Rowsandall.com"
|
subject = "Unrecognized file from Rowsandall.com"
|
||||||
|
|
||||||
plaintext = get_template('csvemail.txt')
|
htmly = get_template('unrecognizedemail.html')
|
||||||
htmly = get_template('csvemail.html')
|
|
||||||
|
|
||||||
d = {'first_name':first_name}
|
d = {'first_name':userfirstname}
|
||||||
|
|
||||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
|
|
||||||
html_content = htmly.render(d)
|
res = send_template_email(from_email,[fullemail],
|
||||||
text_content = textify(html_content)
|
subject,'csvemail.html',d,
|
||||||
|
**kwargs)
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -550,24 +536,11 @@ def handle_sendemailtcx(first_name, last_name, email, tcxfile,**kwargs):
|
|||||||
|
|
||||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
|
|
||||||
html_content = htmly.render(d)
|
|
||||||
text_content = textify(html_content)
|
|
||||||
|
|
||||||
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
res = send_template_email(from_email,[fullemail],
|
||||||
msg.attach_alternative(html_content, "text/html")
|
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)
|
os.remove(tcxfile)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -612,30 +585,10 @@ def handle_sendemailsummary(first_name, last_name, email, csvfile, **kwargs):
|
|||||||
|
|
||||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
|
|
||||||
html_content = htmly.render(d)
|
res = send_template_email(from_email,[fullemail],
|
||||||
text_content = textify(html_content)
|
subject,'summarymail.html',d,
|
||||||
|
attach_file=csvfile,
|
||||||
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
**kwargs)
|
||||||
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()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(csvfile)
|
os.remove(csvfile)
|
||||||
@@ -654,36 +607,14 @@ def handle_sendemailcsv(first_name, last_name, email, csvfile,**kwargs):
|
|||||||
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
|
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
|
||||||
subject = "File from Rowsandall.com"
|
subject = "File from Rowsandall.com"
|
||||||
|
|
||||||
htmly = get_template('csvemail.html')
|
|
||||||
|
|
||||||
d = {'first_name':first_name}
|
d = {'first_name':first_name}
|
||||||
|
|
||||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
|
|
||||||
html_content = htmly.render(d)
|
|
||||||
text_content = textify(html_content)
|
|
||||||
|
|
||||||
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
res = send_template_email(from_email,[fullemail],
|
||||||
msg.attach_alternative(html_content, "text/html")
|
subject,'csvemail.html',d,
|
||||||
|
attach_file=csvfile,**kwargs)
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@@ -819,22 +750,9 @@ def handle_otwsetpower(self,f1, boattype, weightvalue,
|
|||||||
'workoutid':workoutid,
|
'workoutid':workoutid,
|
||||||
}
|
}
|
||||||
|
|
||||||
html_content = htmly.render(d)
|
res = handle_template_email(from_email,[fullemail],
|
||||||
text_content = textify(html_content)
|
subject,'otwpoweremail.html',d,
|
||||||
|
**kwargs)
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -1062,29 +980,19 @@ def handle_sendemail_invite(email, name, code, teamname, manager,
|
|||||||
if debug:
|
if debug:
|
||||||
siteurl = SITE_URL_DEV
|
siteurl = SITE_URL_DEV
|
||||||
|
|
||||||
htmly = get_template('teaminviteemail.html')
|
|
||||||
|
|
||||||
d = {
|
d = {
|
||||||
'name':name,
|
'name':name,
|
||||||
'manage':manager,
|
'manager':manager,
|
||||||
'code':code,
|
'code':code,
|
||||||
'teamname':teamname,
|
'teamname':teamname,
|
||||||
|
'siteurl':siteurl
|
||||||
}
|
}
|
||||||
|
|
||||||
html_content = htmly.render(d)
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
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,'teaminviteemail.html',d,
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -1106,8 +1014,6 @@ def handle_sendemailnewresponse(first_name, last_name,
|
|||||||
siteurl = SITE_URL_DEV
|
siteurl = SITE_URL_DEV
|
||||||
|
|
||||||
|
|
||||||
htmly = get_template('teamresponseemail.html')
|
|
||||||
|
|
||||||
d = {
|
d = {
|
||||||
'first_name':first_name,
|
'first_name':first_name,
|
||||||
'commenter_first_name':commenter_first_name,
|
'commenter_first_name':commenter_first_name,
|
||||||
@@ -1133,29 +1039,31 @@ def handle_sendemailnewcomment(first_name,
|
|||||||
comment, workoutname,
|
comment, workoutname,
|
||||||
workoutid,
|
workoutid,
|
||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fullemail = first_name + ' ' + last_name + ' <' + email + '>'
|
fullemail = first_name + ' ' + last_name + ' <' + email + '>'
|
||||||
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
subject = 'New comment on workout ' + workoutname
|
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,
|
siteurl = SITE_URL
|
||||||
'Rowsandall <info@rowsandall.com>',
|
if debug:
|
||||||
[fullemail])
|
siteurl = SITE_URL_DEV
|
||||||
|
|
||||||
if 'emailbounced' in kwargs:
|
|
||||||
emailbounced = kwargs['emailbounced']
|
|
||||||
else:
|
|
||||||
emailbounced = False
|
|
||||||
|
|
||||||
if not emailbounced:
|
d = {
|
||||||
res = email.send()
|
'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
|
return 1
|
||||||
@@ -1166,28 +1074,22 @@ def handle_sendemail_request(email, name, code, teamname, requestor, id,
|
|||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
fullemail = name + ' <' + email + '>'
|
fullemail = name + ' <' + email + '>'
|
||||||
subject = 'Request to join team ' + teamname
|
subject = 'Request to join team ' + teamname
|
||||||
message = 'Dear ' + name + ',\n\n'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
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"
|
|
||||||
|
|
||||||
email = EmailMessage(subject, message,
|
siteurl = SITE_URL
|
||||||
'Rowsandall <info@rowsandall.com>',
|
if debug:
|
||||||
[fullemail])
|
siteurl = SITE_URL_DEV
|
||||||
|
|
||||||
if 'emailbounced' in kwargs:
|
d = {
|
||||||
emailbounced = kwargs['emailbounced']
|
'requestor':requestor,
|
||||||
else:
|
'teamname':teamname,
|
||||||
emailbounced = False
|
'siteurl':siteurl,
|
||||||
|
'id':id,
|
||||||
|
'first_name':name,
|
||||||
|
}
|
||||||
|
|
||||||
if not emailbounced:
|
res = send_template_email(from_email,[fullemail],subject,
|
||||||
res = email.send()
|
'teamrequestemail.html',d,**kwargs)
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@@ -1198,24 +1100,19 @@ def handle_sendemail_request_accept(email, name, teamname, managername,
|
|||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
fullemail = name + ' <' + email + '>'
|
fullemail = name + ' <' + email + '>'
|
||||||
subject = 'Welcome to ' + teamname
|
subject = 'Welcome to ' + teamname
|
||||||
message = 'Dear ' + name + ',\n\n'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
message += managername
|
|
||||||
message += ' has accepted your request to be part of the team '
|
|
||||||
message += teamname
|
|
||||||
message += '\n\n'
|
|
||||||
message += "Best Regards, the Rowsandall Team"
|
|
||||||
|
|
||||||
email = EmailMessage(subject, message,
|
siteurl = SITE_URL
|
||||||
'Rowsandall <info@rowsandall.com>',
|
if debug:
|
||||||
[fullemail])
|
siteurl = SITE_URL_DEV
|
||||||
|
|
||||||
if 'emailbounced' in kwargs:
|
d = {
|
||||||
emailbounced = kwargs['emailbounced']
|
'first_name':name,
|
||||||
else:
|
'managername':managername,
|
||||||
emailbounced = False
|
'teamname':teamname,
|
||||||
|
}
|
||||||
if not emailbounced:
|
res = send_template_email(from_email,[fullemail],subject,
|
||||||
res = email.send()
|
'teamwelcomeemail.html',d,**kwargs)
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@@ -1226,26 +1123,19 @@ def handle_sendemail_request_reject(email, name, teamname, managername,
|
|||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
fullemail = name + ' <' + email + '>'
|
fullemail = name + ' <' + email + '>'
|
||||||
subject = 'Your application to ' + teamname + ' was rejected'
|
subject = 'Your application to ' + teamname + ' was rejected'
|
||||||
message = 'Dear ' + name + ',\n\n'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
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"
|
|
||||||
|
|
||||||
email = EmailMessage(subject, message,
|
siteurl = SITE_URL
|
||||||
'Rowsandall <info@rowsandall.com>',
|
if debug:
|
||||||
[fullemail])
|
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,
|
||||||
|
'teamrejectemail.html',d,**kwargs)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -1255,25 +1145,19 @@ def handle_sendemail_member_dropped(email, name, teamname, managername,
|
|||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
fullemail = name + ' <' + email + '>'
|
fullemail = name + ' <' + email + '>'
|
||||||
subject = 'You were removed from ' + teamname
|
subject = 'You were removed from ' + teamname
|
||||||
message = 'Dear ' + name + ',\n\n'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
message += 'Unfortunately, '
|
|
||||||
message += managername
|
|
||||||
message += ' has removed you from the team '
|
|
||||||
message += teamname
|
|
||||||
message += '\n\n'
|
|
||||||
message += "Best Regards, the Rowsandall Team"
|
|
||||||
|
|
||||||
email = EmailMessage(subject, message,
|
siteurl = SITE_URL
|
||||||
'Rowsandall <info@rowsandall.com>',
|
if debug:
|
||||||
[fullemail])
|
siteurl = SITE_URL_DEV
|
||||||
|
|
||||||
if 'emailbounced' in kwargs:
|
d = {
|
||||||
emailbounced = kwargs['emailbounced']
|
'first_name':name,
|
||||||
else:
|
'managername':managername,
|
||||||
emailbounced = False
|
'teamname':teamname,
|
||||||
|
}
|
||||||
if not emailbounced:
|
res = send_template_email(from_email,[fullemail],subject,
|
||||||
res = email.send()
|
'teamdropemail.html',d,**kwargs)
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@@ -1282,28 +1166,22 @@ def handle_sendemail_member_dropped(email, name, teamname, managername,
|
|||||||
@app.task
|
@app.task
|
||||||
def handle_sendemail_team_removed(email, name, teamname, managername,
|
def handle_sendemail_team_removed(email, name, teamname, managername,
|
||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
|
|
||||||
fullemail = name + ' <' + email + '>'
|
fullemail = name + ' <' + email + '>'
|
||||||
subject = 'Team ' + teamname + ' was deleted'
|
subject = 'You were removed from ' + teamname
|
||||||
message = 'Dear ' + name + ',\n\n'
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
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"
|
|
||||||
|
|
||||||
email = EmailMessage(subject, message,
|
siteurl = SITE_URL
|
||||||
'Rowsandall <info@rowsandall.com>',
|
if debug:
|
||||||
[fullemail])
|
siteurl = SITE_URL_DEV
|
||||||
|
|
||||||
if 'emailbounced' in kwargs:
|
d = {
|
||||||
emailbounced = kwargs['emailbounced']
|
'first_name':name,
|
||||||
else:
|
'managername':managername,
|
||||||
emailbounced = False
|
'teamname':teamname,
|
||||||
|
}
|
||||||
if not emailbounced:
|
res = send_template_email(from_email,[fullemail],subject,
|
||||||
res = email.send()
|
'teamremoveemail.html',d,**kwargs)
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@@ -1314,26 +1192,20 @@ def handle_sendemail_invite_reject(email, name, teamname, managername,
|
|||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
fullemail = managername + ' <' + email + '>'
|
fullemail = managername + ' <' + email + '>'
|
||||||
subject = 'Your invitation to ' + name + ' was rejected'
|
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,
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
'Rowsandall <info@rowsandall.com>',
|
|
||||||
[fullemail])
|
|
||||||
|
|
||||||
if 'emailbounced' in kwargs:
|
siteurl = SITE_URL
|
||||||
emailbounced = kwargs['emailbounced']
|
if debug:
|
||||||
else:
|
siteurl = SITE_URL_DEV
|
||||||
emailbounced = False
|
|
||||||
|
|
||||||
if not emailbounced:
|
|
||||||
res = email.send()
|
|
||||||
|
|
||||||
|
d = {
|
||||||
|
'first_name':name,
|
||||||
|
'managername':managername,
|
||||||
|
'teamname':teamname,
|
||||||
|
}
|
||||||
|
res = send_template_email(from_email,[fullemail],subject,
|
||||||
|
'teaminviterejectemail.html',d,**kwargs)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -1343,21 +1215,20 @@ def handle_sendemail_invite_accept(email, name, teamname, managername,
|
|||||||
debug=False,**kwargs):
|
debug=False,**kwargs):
|
||||||
fullemail = managername + ' <' + email + '>'
|
fullemail = managername + ' <' + email + '>'
|
||||||
subject = 'Your invitation to ' + name + ' was accepted'
|
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,
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
'Rowsandall <info@rowsandall.com>',
|
|
||||||
[fullemail])
|
|
||||||
|
|
||||||
if 'emailbounced' in kwargs:
|
siteurl = SITE_URL
|
||||||
emailbounced = kwargs['emailbounced']
|
if debug:
|
||||||
else:
|
siteurl = SITE_URL_DEV
|
||||||
emailbounced = False
|
|
||||||
|
|
||||||
if not emailbounced:
|
d = {
|
||||||
res = email.send()
|
'first_name':name,
|
||||||
|
'managername':managername,
|
||||||
|
'teamname':teamname,
|
||||||
|
}
|
||||||
|
res = send_template_email(from_email,[fullemail],subject,
|
||||||
|
'teaminviteacceptemail.html',d,**kwargs)
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -393,6 +393,7 @@ def send_request_email(rekwest):
|
|||||||
code = rekwest.code
|
code = rekwest.code
|
||||||
teamname = rekwest.team.name
|
teamname = rekwest.team.name
|
||||||
requestor = rekwest.user.first_name+' '+rekwest.user.last_name
|
requestor = rekwest.user.first_name+' '+rekwest.user.last_name
|
||||||
|
print requestor,'aap'
|
||||||
|
|
||||||
res = myqueue(queuehigh,
|
res = myqueue(queuehigh,
|
||||||
handle_sendemail_request,
|
handle_sendemail_request,
|
||||||
|
|||||||
16
rowers/templates/teamdropemail.html
Normal file
16
rowers/templates/teamdropemail.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Unfortunately,
|
||||||
|
{{ managername }} has removed you from
|
||||||
|
the team {{ teamname }}.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
16
rowers/templates/teaminviteacceptemail.html
Normal file
16
rowers/templates/teaminviteacceptemail.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>Dear <strong>{{ managername }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ first_name }} has accepted your invitation to be
|
||||||
|
part of the team {{ teamname }}.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
17
rowers/templates/teaminviterejectemail.html
Normal file
17
rowers/templates/teaminviterejectemail.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>Dear <strong>{{ managername }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Unfortunately,
|
||||||
|
{{ first_name }} has rejected your invitation to be
|
||||||
|
part of the team {{ teamname }}.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
16
rowers/templates/teamrejectemail.html
Normal file
16
rowers/templates/teamrejectemail.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Unfortunately,
|
||||||
|
{{ managername }} has rejected your request to be part
|
||||||
|
of the team {{ teamname }}.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
19
rowers/templates/teamremoveemail.html
Normal file
19
rowers/templates/teamremoveemail.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ managername }} has decided to delete the team {{ teamname }}.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The {{ teamname }} tag has been removed from all your
|
||||||
|
workouts on rowsandall.com
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
29
rowers/templates/teamrequestemail.html
Normal file
29
rowers/templates/teamrequestemail.html
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ requestor }} is requesting access to your team {{ teamname }}
|
||||||
|
on rowsandall.com
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Click the direct link to accept:
|
||||||
|
<a href="{{ siteurl }}/rowers/me/request/{{ code }}">
|
||||||
|
{{ siteurl }}/rowers/me/request/{{ code }}</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Click the following link to reject the request:
|
||||||
|
<a href="{{ siteurl }}/rowers/me/request/{{ id }}">
|
||||||
|
{{ siteurl }}/rowers/me/request/{{ id }}</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
You can find all pending requests on your team management page:
|
||||||
|
<a href="{{ siteurl }}/rowers/me/teams">{{ siteurl }}/rowers/me/teams</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{ commenter_first_name }} {{ commenter_last_name }} has written
|
{{ commenter_first_name }} {{ commenter_last_name }} has written
|
||||||
a new comment on your workout {{ workoutname }}
|
a new comment on workout {{ workoutname }}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
{{ comment }}
|
{{ comment }}
|
||||||
|
|||||||
15
rowers/templates/teamwelcomeemail.html
Normal file
15
rowers/templates/teamwelcomeemail.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{% extends "emailbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ managername }} has accepted your request to be part
|
||||||
|
of the team {{ teamname }}.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Best Regards, the Rowsandall Team
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user