From 8aa54922b7c213d18f1bacac9196b7f71d298b3e Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 12 Nov 2011 19:43:23 +0100 Subject: [PATCH] fix e-mail templates --- pandora/user/templates/contact_email.txt | 8 ++++--- pandora/user/templates/contact_receipt.txt | 11 +++++----- .../user/templates/password_reset_email.txt | 3 ++- pandora/user/views.py | 21 ++++++++++++------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/pandora/user/templates/contact_email.txt b/pandora/user/templates/contact_email.txt index b300f1ba1..f50c8bfa1 100644 --- a/pandora/user/templates/contact_email.txt +++ b/pandora/user/templates/contact_email.txt @@ -1,5 +1,7 @@ -{{name}} <{{email}}> sent a contact message: +From: {{name}} <{{email}}> +Subject: {{subject}} + {{message}} --- -{{sitename}} +-- +{{sitename}} - {{url}} diff --git a/pandora/user/templates/contact_receipt.txt b/pandora/user/templates/contact_receipt.txt index 99e5f4be0..a2f4b159f 100644 --- a/pandora/user/templates/contact_receipt.txt +++ b/pandora/user/templates/contact_receipt.txt @@ -1,7 +1,8 @@ -{{name}}, -thanks for your message, we will get back to you shortly. -here your message for forther reference +From: {{name}} <{{from}}> +To: {{sitename}} <{{to}}> +Subject: {{subject}} + {{message}} --- -{{sitename}} +-- +{{sitename}} - {{url}} diff --git a/pandora/user/templates/password_reset_email.txt b/pandora/user/templates/password_reset_email.txt index d0d748b04..1f39ceca3 100644 --- a/pandora/user/templates/password_reset_email.txt +++ b/pandora/user/templates/password_reset_email.txt @@ -2,6 +2,7 @@ To reset your password, please use the following code: {{code}} -If you do not want to reset your password, no further action is required. +If you don't want to reset your password, no further action is required. +-- {{sitename}} - {{url}} diff --git a/pandora/user/views.py b/pandora/user/views.py index f78b3579b..f9c325483 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -278,9 +278,9 @@ def requestToken(request): template = loader.get_template('password_reset_email.txt') context = RequestContext(request, { - 'url': request.build_absolute_uri("/"), 'code': code, 'sitename': settings.SITENAME, + 'url': request.build_absolute_uri('/'), }) message = template.render(context) subject = '%s - Reset Password' % settings.SITENAME @@ -548,18 +548,20 @@ def contact(request): if 'message' in data and data['message'].strip(): email_from = settings.CONFIG['site']['email']['system'] email_to = [settings.CONFIG['site']['email']['contact'], ] + subject = data.get('subject', '').strip() template = loader.get_template('contact_email.txt') context = RequestContext(request, { - 'email': email, - 'message': data['message'].strip(), 'name': name, + 'email': email, + 'subject': subject + 'message': data['message'].strip(), 'sitename': settings.SITENAME, + 'url': request.build_absolute_uri('/'), }) message = template.render(context) - subject = (u'[%s Contact] %s' % (settings.SITENAME, data.get('subject', ''))).strip() response = json_response(text='message sent') try: - send_mail(subject.strip(), message, email_from, email_to) + send_mail(u'[%s Contact] %s' % (settings.SITENAME, subject), message, email_from, email_to) except BadHeaderError: response = json_response(status=400, text='invalid data') if request.user.is_authenticated() \ @@ -567,14 +569,17 @@ def contact(request): and data['receipt']: template = loader.get_template('contact_receipt.txt') context = RequestContext(request, { - 'email': email, - 'message': data['message'].strip(), 'name': name, + 'from': email, 'sitename': settings.SITENAME, + 'to': email_to, + 'subject': subject, + 'message': data['message'].strip(), + 'url': request.build_absolute_uri('/'), }) message = template.render(context) try: - send_mail(subject.strip(), message, email_from, [email]) + send_mail('Fwd: %s' % subject, message, email_from, [email]) except: pass else: