[extensions-web] Use the Django template system to format sent emails
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Use the Django template system to format sent emails
- Date: Tue, 1 Nov 2011 14:47:33 +0000 (UTC)
commit da720dccec285b18839be5b4a0a2565691282bb7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Oct 31 17:19:16 2011 -0400
Use the Django template system to format sent emails
.../review/templates/review/reviewed_mail.txt | 9 +++
.../templates/review/reviewed_mail_subject.txt | 1 +
.../review/templates/review/submitted_mail.txt | 7 +++
.../templates/review/submitted_mail_subject.txt | 1 +
sweettooth/review/views.py | 57 +++++++------------
5 files changed, 39 insertions(+), 36 deletions(-)
---
diff --git a/sweettooth/review/templates/review/reviewed_mail.txt b/sweettooth/review/templates/review/reviewed_mail.txt
new file mode 100644
index 0000000..c9660ac
--- /dev/null
+++ b/sweettooth/review/templates/review/reviewed_mail.txt
@@ -0,0 +1,9 @@
+Your extension, "{{ extension.name }}", version {{ version.version }} has been reviewed. You can see the review here:
+
+{{ url }}
+
+Please use the review page to follow up with any comments or concerns.
+
+â
+
+This email was sent automatically by GNOME Shell Extensions. Do not reply.
diff --git a/sweettooth/review/templates/review/reviewed_mail_subject.txt b/sweettooth/review/templates/review/reviewed_mail_subject.txt
new file mode 100644
index 0000000..0fdc549
--- /dev/null
+++ b/sweettooth/review/templates/review/reviewed_mail_subject.txt
@@ -0,0 +1 @@
+GNOME Shell Extensions â Your extension, "{{ extension.name }}", v{{ version.version }} has been reviewed.
diff --git a/sweettooth/review/templates/review/submitted_mail.txt b/sweettooth/review/templates/review/submitted_mail.txt
new file mode 100644
index 0000000..bf8561e
--- /dev/null
+++ b/sweettooth/review/templates/review/submitted_mail.txt
@@ -0,0 +1,7 @@
+A new extension version, "{{ extension.name }}", version {{ version.version }} has been submitted for review by {{ extension.creator }}.
+
+Please review the extension at {{ url }}
+
+â
+
+This email was sent automatically by GNOME Shell Extensions. Do not reply.
diff --git a/sweettooth/review/templates/review/submitted_mail_subject.txt b/sweettooth/review/templates/review/submitted_mail_subject.txt
new file mode 100644
index 0000000..4962483
--- /dev/null
+++ b/sweettooth/review/templates/review/submitted_mail_subject.txt
@@ -0,0 +1 @@
+GNOME Shell Extensions â New review request: "{{ extension.name }}", v{{ version.version }}
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index bb56c7f..b5b2a4e 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -18,6 +18,7 @@ from django.core.urlresolvers import reverse
from django.contrib import messages
from django.http import HttpResponseForbidden
from django.shortcuts import redirect
+from django.template.loader import render_to_string
from review.models import CodeReview, ChangeStatusLog, get_all_reviewers
from extensions import models
@@ -156,52 +157,31 @@ def review_version_view(request, obj):
return render(request, template_name, context)
-on_submitted_subject = u"""
-GNOME Shell Extensions \N{EM DASH} New review request: "%(name)s", v%(ver)d
-""".strip()
-
-on_submitted_template = u"""
-A new extension version, "%(name)s", version %(ver)d has been submitted for review by %(creator)s.
-
-Review the extension at %(url)s
-
-\N{EM DASH}
-
-This email was sent automatically by GNOME Shell Extensions. Do not reply.
-""".strip()
-
def send_email_on_submitted(request, version, **kwargs):
extension = version.extension
url = request.build_absolute_uri(reverse('review-version',
kwargs=dict(pk=version.pk)))
- data = dict(ver=version.version,
- name=extension.name,
- creator=extension.creator,
+ data = dict(version=version,
+ extension=extension,
url=url)
reviewers = get_all_reviewers().values_list('email', flat=True)
- send_mail(subject=on_submitted_subject % data,
- message=on_submitted_template % data,
+ subject = render_to_string('review/submitted_mail_subject.txt', data).strip()
+ subject = subject.replace('\n', '')
+ subject = subject.replace('\r', '')
+
+ message = render_to_string('review/submitted_mail.txt', data).strip()
+
+ send_mail(subject=subject,
+ message=message,
from_email=settings.EMAIL_SENDER,
recipient_list=reviewers)
models.submitted_for_review.connect(send_email_on_submitted)
-on_reviewed_subject = u"""
-GNOME Shell Extensions \N{EM DASH} Your extension, "%(name)s", v%(ver)d has been reviewed.
-""".strip()
-
-on_reviewed_template = u"""
-Your extension, "%(name)s", version %(ver)d has been reviewed. You can see the review here:
-
-%(url)s
-
-Please use the review page to follow up with any comments or concerns.
-""".strip()
-
def send_email_on_reviewed(request, version, review, **kwargs):
extension = version.extension
@@ -212,13 +192,18 @@ def send_email_on_reviewed(request, version, review, **kwargs):
url = request.build_absolute_uri(reverse('review-version',
kwargs=dict(pk=version.pk)))
- data = dict(ver=version.version,
- name=extension.name,
- creator=extension.creator,
+ data = dict(version=version,
+ extension=extension,
url=url)
- send_mail(subject=on_reviewed_subject % data,
- message=on_reviewed_template % data,
+ subject = render_to_string('review/reviewed_mail_subject.txt', data).strip()
+ subject = subject.replace('\n', '')
+ subject = subject.replace('\r', '')
+
+ message = render_to_string('review/reviewed_mail.txt', data).strip()
+
+ send_mail(subject=subject,
+ message=message,
from_email=settings.EMAIL_SENDER,
recipient_list=[extension.creator.email])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]