From 0dadcf32a62ffc00cc98dde6c82f0efd51e48315 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 19 Mar 2018 17:48:47 +0100 Subject: [PATCH] a few more templates --- rowers/tasks.py | 90 ++++++++++++------------- rowers/templates/teaminviteemail.html | 58 ++++++++++++++++ rowers/templates/teamresponseemail.html | 26 +++++++ 3 files changed, 128 insertions(+), 46 deletions(-) create mode 100644 rowers/templates/teaminviteemail.html create mode 100644 rowers/templates/teamresponseemail.html diff --git a/rowers/tasks.py b/rowers/tasks.py index 6b0d06a9..6e882bcd 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -631,7 +631,6 @@ def handle_sendemailcsv(first_name, last_name, email, csvfile,**kwargs): fullemail = first_name + " " + last_name + " " + "<" + email + ">" subject = "File from Rowsandall.com" - plaintext = get_template('csvemail.txt') htmly = get_template('csvemail.html') d = {'first_name':first_name} @@ -1035,34 +1034,25 @@ def handle_sendemail_invite(email, name, code, teamname, manager, debug=False,**kwargs): fullemail = name + ' <' + email + '>' subject = 'Invitation to join team ' + teamname - message = 'Dear ' + name + ',\n\n' - message += manager + ' is inviting you to join his team ' + teamname - message += ' on rowsandall.com\n\n' - message += 'By accepting the invite, you will have access to your' - message += " team's workouts on rowsandall.com and your workouts will " - message += " be visible to " - message += "the members of the team.\n\n" - message += "By accepting the invite, you are agreeing with the sharing " - message += "of personal data according to our privacy policy.\n\n" - message += 'If you already have an account on rowsandall.com, you can login to the site and you will find the invitation here on the Teams page:\n' - message += ' https://rowsandall.com/rowers/me/teams \n\n' - message += 'You can also click the direct link: \n' - message += 'https://rowsandall.com/rowers/me/invitation/' + code + ' \n\n' - message += 'If you are not yet registered to rowsandall.com, ' - message += 'you can register for free at https://rowsandall.com/rowers/register\n' - message += 'After you set up your account, you can use the direct link: ' - message += 'https://rowsandall.com/rowers/me/invitation/' + code + ' \n\n' - message += 'You can also manually accept your team membership with the code.\n' - message += 'You will need to do this if you registered under a different email address than this one.\n' - message += 'Code: ' + code + '\n' - message += 'Link to manually accept your team membership: ' - message += 'https://rowsandall.com/rowers/me/invitation\n\n' - message += "Best Regards, the Rowsandall Team" + siteurl = SITE_URL + if debug: + siteurl = SITE_URL_DEV - email = EmailMessage(subject, message, - 'Rowsandall ', - [fullemail]) + htmly = get_template('teaminviteemail.html') + + d = { + 'name':name, + 'manage':manager, + 'code':code, + 'teamname':teamname, + } + + 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'] @@ -1070,7 +1060,7 @@ def handle_sendemail_invite(email, name, code, teamname, manager, emailbounced = False if not emailbounced: - res = email.send() + res = msg.send() return 1 @@ -1085,25 +1075,33 @@ def handle_sendemailnewresponse(first_name, last_name, workoutname, workoutid, commentid, debug=False,**kwargs): fullemail = first_name + ' ' + last_name + ' <' + email + '>' + from_email = 'Rowsandall ' 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 the 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' - message += '\n\n' - message += 'You are receiving this email because you are subscribed ' - message += 'to comments on this workout. To unsubscribe, follow this link:\n' - message += 'https://rowsandall.com/rowers/workout/' + \ - str(workoutid) + '/unsubscribe' - email = EmailMessage(subject, message, - 'Rowsandall ', - [fullemail]) + siteurl = SITE_URL + if debug: + siteurl = SITE_URL_DEV + + + htmly = get_template('teamresponseemail.html') + + 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 + } + + 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'] @@ -1111,7 +1109,7 @@ def handle_sendemailnewresponse(first_name, last_name, emailbounced = False if not emailbounced: - res = email.send() + res = msg.send() return 1 diff --git a/rowers/templates/teaminviteemail.html b/rowers/templates/teaminviteemail.html new file mode 100644 index 00000000..f0895252 --- /dev/null +++ b/rowers/templates/teaminviteemail.html @@ -0,0 +1,58 @@ +{% extends "emailbase.html" %} +{% load staticfiles %} +{% load rowerfilters %} + +{% block body %} +

Dear {{ name }},

+ +

+ {{ manager }} is inviting you to join his team {{ teamname }} + on rowsandall.com +

+

+ By accepting the invite, you will have access to your + team's workouts on rowsandall.com and your workouts will + be visible to + the members of the team. +

+

+ By accepting the invite, you are agreeing with the sharing + of personal data according to our privacy policy. +

+

+ If you already have an account on rowsandall.com, you can login to the + site and you will find the invitation here on the Teams page: + {{ siteurl }}/rowers/me/teams +

+

+ You can also click the direct link: + + {{ siteurl }}/rowers/me/invitation/{{ code }} +

+

+ If you are not yet registered to rowsandall.com, + you can register for free at + {{ siteurl }}/rowers/register +

+

+ After you set up your account, you can use the direct link: + + {{ siteurl }}/rowers/me/invitation/{{ code }} +

+

+ You can also manually accept your team membership with the code. + You will need to do this if you registered under a different email address than this one. +

+

+ Code: {{ code }} +

+

+ Link to manually accept your team membership: + + {{ siteurl }}/rowers/me/invitation +

+ +

+ Best Regards, the Rowsandall Team +

+{% endblock %} diff --git a/rowers/templates/teamresponseemail.html b/rowers/templates/teamresponseemail.html new file mode 100644 index 00000000..3bb04e19 --- /dev/null +++ b/rowers/templates/teamresponseemail.html @@ -0,0 +1,26 @@ +{% extends "emailbase.html" %} +{% load staticfiles %} +{% load rowerfilters %} + +{% block body %} +

Dear {{ name }},

+ +

+ {{ commenter_first_name }} {{ commenter_last_name }} has written + a new comment on your workout {{ workoutname }} +

+

+ {{ comment }} +

+

+ You can read the comment here: +

+

+ + {{ siteurl }}/rowers/workout/{{ workoutid }}/comment +

+ +

+ Best Regards, the Rowsandall Team +

+{% endblock %}