diff --git a/rowers/mailprocessing.py b/rowers/mailprocessing.py index da8073fc..08c727fc 100644 --- a/rowers/mailprocessing.py +++ b/rowers/mailprocessing.py @@ -33,25 +33,23 @@ queuelow = django_rq.get_queue('low') queuehigh = django_rq.get_queue('default') # Sends a confirmation with a link to the workout - +from rowers.emails import send_template_email def send_confirm(user, name, link, options): - """ Send confirmation email to user when email has been processed """ + d = { + 'first_name':user.first_name, + 'name':name, + 'link':link, + } + fullemail = user.email - subject = 'Workout added: ' + name - message = 'Dear ' + user.first_name + ',\n\n' - message += "Your workout has been added to Rowsandall.com.\n" - message += "Link to workout: " + link + "\n\n" - message += "Best Regards, the Rowsandall Team" - - if options: - message += "\n\n" + str(options) - - email = EmailMessage(subject, message, - 'Rowsandall ', - [fullemail]) - - res = email.send() + subject = 'New Workout Added: '+name + + res = send_template_email('Rowsandall ', + [fullemail], + subject,'confirmemail.html', + d + ) return 1 diff --git a/rowers/management/commands/processemail.py b/rowers/management/commands/processemail.py index 80540061..35b175d2 100644 --- a/rowers/management/commands/processemail.py +++ b/rowers/management/commands/processemail.py @@ -83,8 +83,12 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False): plottype, title, imagename=imagename ) + email_sent = send_confirm( + rower.user, title, link, + uploadoptions + ) try: - if workoutid and not testing: + if workoutid: email_sent = send_confirm( rower.user, title, link, uploadoptions @@ -92,13 +96,12 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False): time.sleep(10) except: try: - if not testing: - time.sleep(10) - if workoutid: - email_sent = send_confirm( - rower.user, title, link, - uploadoptions - ) + time.sleep(10) + if workoutid: + email_sent = send_confirm( + rower.user, title, link, + uploadoptions + ) except: pass diff --git a/rowers/templates/confirmemail.html b/rowers/templates/confirmemail.html new file mode 100644 index 00000000..0fd847e0 --- /dev/null +++ b/rowers/templates/confirmemail.html @@ -0,0 +1,18 @@ +{% extends "emailbase.html" %} + +{% block body %} +

Dear {{ first_name }},

+ +

+ Your workout has been added to Rowsandall.com. +

+ +

+ Link to workout: {{ link }} +

+ + +

+ Best Regards, the Rowsandall Team +

+{% endblock %}