Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Change `emailit` package to `django templated email`

Pacu279cf80575a79
diff --git a/requirements.in b/requirements.in
index 6535f045f6..165e341972 100644
--- a/requirements.in
+++ b/requirements.in
@@ -7,7 +7,6 @@ dj_email_url>=0.0.4
django-bootstrap3>=8.2.1
django-cache-url>=1.0.0
django-countries>=4.1
-django-emailit>=0.2.2
django-mptt>=0.7.1
django-payments>=0.11.0,<0.12a0
django-prices>=0.4.11,<0.5a0
@@ -15,6 +14,7 @@ django-prices-openexchangerates>=0.1.12,<0.2a0
django-redis>=4.0.0
djangorestframework>=3.1
django-storages>=1.4.1
+django-templated-email>=2.2.0
django-versatileimagefield>=1.0.1
django-webpack-loader>=0.3.0
elasticsearch>=2.0.0,<3.0.0
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 10d0b78815..bdf182343f 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
from decimal import Decimal
from uuid import uuid4
-import emailit.api
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
@@ -17,6 +16,7 @@ from payments import PaymentStatus, PurchasedItem
from payments.models import BasePayment
from prices import Price, FixedDiscount
from satchless.item import ItemLine, ItemSet
+from templated_email import send_templated_mail
from ..core.utils import build_absolute_uri
from ..discount.models import Voucher
@@ -173,10 +173,9 @@ class Order(models.Model, ItemSet, index.Indexed):
payment_url = build_absolute_uri(
reverse('order:details', kwargs={'token': self.token}))
context = {'payment_url': payment_url}
-
- emailit.api.send_mail(
- email, context, 'order/emails/confirm_email',
- from_email=settings.ORDER_FROM_EMAIL)
+ send_templated_mail(
+ 'order/confirm_order', from_email=settings.ORDER_FROM_EMAIL,
+ recipient_list=[email], context=context)
def get_last_payment_status(self):
last_payment = self.payments.last()
@@ -410,9 +409,9 @@ class Payment(BasePayment):
order_url = build_absolute_uri(
reverse('order:details', kwargs={'token': self.order.token}))
context = {'order_url': order_url}
- emailit.api.send_mail(
- email, context, 'order/payment/emails/confirm_email',
- from_email=settings.ORDER_FROM_EMAIL)
+ send_templated_mail(
+ 'order/payment/confirm_payment', context=context,
+ from_email=settings.ORDER_FROM_EMAIL, recipient_list=[email])
def get_purchased_items(self):
items = [
diff --git a/saleor/settings.py b/saleor/settings.py
index fd4f9dbf6a..5f22913f4c 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -65,7 +65,7 @@ EMAIL_USE_SSL = email_config['EMAIL_USE_SSL']
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL')
ORDER_FROM_EMAIL = os.getenv('ORDER_FROM_EMAIL', DEFAULT_FROM_EMAIL)
-
+TEMPLATED_EMAIL_BACKEND = 'templated_email.backends.vanilla_django.TemplateBackend'
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
@@ -172,7 +172,6 @@ INSTALLED_APPS = [
'bootstrap3',
'django_prices',
'django_prices_openexchangerates',
- 'emailit',
'graphene_django',
'mptt',
'payments',
diff --git a/templates/order/emails/confirm_email.body.txt b/templates/order/emails/confirm_email.body.txt
deleted file mode 100644
index e3a119cbfb..0000000000
--- a/templates/order/emails/confirm_email.body.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-{% load i18n %}
-
-{% block content %}{% blocktrans context "Order confirmation email text" %}Hi!
-
-Thank you for your order. To see your payment details please visit:
-{{ payment_url }}
-
-Sincerely,
-Saleor Team{% endblocktrans %}{% endblock %}
diff --git a/templates/order/emails/confirm_email.subject.txt b/templates/order/emails/confirm_email.subject.txt
deleted file mode 100644
index e773865b63..0000000000
--- a/templates/order/emails/confirm_email.subject.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-{% load i18n %}
-{% trans "Order details" context "Order confirmation email subject" %}
diff --git a/templates/order/payment/emails/confirm_email.subject.txt b/templates/order/payment/emails/confirm_email.subject.txt
deleted file mode 100644
index 0143237705..0000000000
--- a/templates/order/payment/emails/confirm_email.subject.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-{% load i18n %}
-{% trans "Payment details" context "Payment confirmation subject" %}
diff --git a/templates/templated_email/order/confirm_order.email b/templates/templated_email/order/confirm_order.email
new file mode 100644
index 0000000000..33a44f12c1
--- /dev/null
+++ b/templates/templated_email/order/confirm_order.email
@@ -0,0 +1,15 @@
+{% block html %}
+{% load i18n %}
+
+{% block subject %}
+{% trans "Order details" context "Order confirmation email subject" %}
+{% endblock %}
+
+{% block content %}{% blocktrans context "Order confirmation email text" %}Hi!
+
+Thank you html for your order. To see your payment details please visit:
+{{ payment_url }}
+
+Sincerely,
+Saleor Team{% endblocktrans %}{% endblock %}
+{% endblock %}
diff --git a/templates/order/payment/emails/confirm_email.body.txt b/templates/templated_email/order/payment/confirm_payment.email
similarity index 59%
rename from templates/order/payment/emails/confirm_email.body.txt
rename to templates/templated_email/order/payment/confirm_payment.email
index abdc826bb5..b732d7b36c 100644
--- a/templates/order/payment/emails/confirm_email.body.txt
+++ b/templates/templated_email/order/payment/confirm_payment.email
@@ -1,9 +1,16 @@
+{% block html %}
{% load i18n %}
-{% block content %}{% blocktrans context "Payment confirmation email text" %}Hi!
+{% block subject %}
+{% trans "Payment details" context "Payment confirmation subject" %}
+{% endblock %}
+{% block content %}{% blocktrans context "Payment confirmation email text" %}Hi!
+<div class="footer">
Thank you for your payment. To see your payment details please visit:
+</div>
{{ order_url }}
Sincerely,
Saleor Team{% endblocktrans %}{% endblock %}
+{% endblock %}