Skip to content

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

Restructure emails and commands so it works on Windows

Patryk Zawadzki967c8360846b
diff --git a/.gitignore b/.gitignore
index 628711b011..316ab68275 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,4 +28,5 @@ dist/
/static/
/saleor/static/assets/
webpack-bundle.json
-/templates/templated_email/compiled/
+/templates/templated_email/compiled/*
+!/templates/templated_email/compiled/.gitkeep
diff --git a/docs/customization/emails.rst b/docs/customization/emails.rst
index 3c64059eb7..c6ea6eb5b6 100644
--- a/docs/customization/emails.rst
+++ b/docs/customization/emails.rst
@@ -11,9 +11,11 @@ Emails are sent with `Django-Templated-Email <https://github.com/vintasoftware/d
Customizing Email Templates
----------------------------
-Templates for emails live in ``templates/templated_email`` which has two subdirectories. ``source`` directory contains ``*.email`` and ``*.mjml`` files next to each other, grouped by apps' name. Those MJML files are compiled to ``*.html`` and put into ``compiled`` directory.
+Templates for emails live in ``templates/templated_email``. App-specific directories contain ``*.email`` files that define each specific message type.
-Plain emails in ``*.email`` include HTML version by referencing compiled ``*.html`` files.
+The ``source`` directory contains ``*.mjml`` files. Those MJML files are compiled to ``*.html`` and put into ``compiled`` directory.
+
+Emails defined in ``*.email`` files include their HTML versions by referencing the compiled ``*.html`` files.
Compiling MJML
diff --git a/package-lock.json b/package-lock.json
index 69fe37677a..7997c8e9fb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11387,9 +11387,9 @@
}
},
"node-sass": {
- "version": "4.8.3",
- "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.8.3.tgz",
- "integrity": "sha512-tfFWhUsCk/Y19zarDcPo5xpj+IW3qCfOjVdHtYeG6S1CKbQOh1zqylnQK6cV3z9k80yxAnFX9Y+a9+XysDhhfg==",
+ "version": "4.9.0",
+ "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.9.0.tgz",
+ "integrity": "sha512-QFHfrZl6lqRU3csypwviz2XLgGNOoWQbo2GOvtsfQqOfL4cy1BtWnhx/XUeAO9LT3ahBzSRXcEO6DdvAH9DzSg==",
"dev": true,
"requires": {
"async-foreach": "0.1.3",
diff --git a/package.json b/package.json
index b49c09e7e1..05d32fdb44 100644
--- a/package.json
+++ b/package.json
@@ -59,7 +59,7 @@
"file-loader": "^1.1.11",
"mini-css-extract-plugin": "^0.4.0",
"mjml": "^3.3.5",
- "node-sass": "^4.8.3",
+ "node-sass": "^4.9.0",
"postcss": "^6.0.21",
"postcss-loader": "^2.1.3",
"sass-loader": "^6.0.7",
@@ -89,6 +89,6 @@
"build-assets": "webpack -p --progress",
"heroku-postbuild": "npm run build-assets && npm run build-emails",
"start": "webpack -d --watch --progress",
- "build-emails": "mkdir -p templates/templated_email/compiled/ && find templates -name \"*.mjml\" -not -path \"templates/templated_email/source/*partials/*\" -not -path \"templates/templated_email/source/*shared/*\" -exec mjml -l skip {} -o templates/templated_email/compiled/ \\;"
+ "build-emails": "mjml -l skip \"templates/templated_email/source/*.mjml\" -o templates/templated_email/compiled"
}
}
diff --git a/saleor/account/emails.py b/saleor/account/emails.py
index 1d3c69b822..ea64d8e5ce 100644
--- a/saleor/account/emails.py
+++ b/saleor/account/emails.py
@@ -14,7 +14,7 @@ def send_password_reset_email(context, recipient):
kwargs={'uidb64': context['uid'], 'token': context['token']}))
context['reset_url'] = reset_url
send_templated_mail(
- template_name='source/account/password_reset',
+ template_name='account/password_reset',
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[recipient],
context=context)
diff --git a/saleor/dashboard/emails.py b/saleor/dashboard/emails.py
index 173ac37fde..266c7f6a72 100644
--- a/saleor/dashboard/emails.py
+++ b/saleor/dashboard/emails.py
@@ -20,7 +20,7 @@ def send_set_password_email(staff):
'uid': urlsafe_base64_encode(force_bytes(staff.pk)).decode(),
'token': default_token_generator.make_token(staff)}
send_templated_mail(
- template_name='source/dashboard/staff/set_password',
+ template_name='dashboard/staff/set_password',
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[staff.email],
context=ctx)
@@ -35,7 +35,7 @@ def send_promote_customer_to_staff_email(staff):
'url': build_absolute_uri(reverse('dashboard:index')),
'site_name': site.name}
send_templated_mail(
- template_name='source/dashboard/staff/promote_customer',
+ template_name='dashboard/staff/promote_customer',
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[staff.email],
context=ctx)
diff --git a/saleor/order/emails.py b/saleor/order/emails.py
index 2d22c79f4b..521d2c3d58 100644
--- a/saleor/order/emails.py
+++ b/saleor/order/emails.py
@@ -8,11 +8,11 @@ from ..core.utils import build_absolute_uri
from ..seo.schema.email import get_order_confirmation_markup
from .models import Fulfillment, Order
-CONFIRM_ORDER_TEMPLATE = 'source/order/confirm_order'
-CONFIRM_FULFILLMENT_TEMPLATE = 'source/order/confirm_fulfillment'
-UPDATE_FULFILLMENT_TEMPLATE = 'source/order/update_fulfillment'
-CONFIRM_PAYMENT_TEMPLATE = 'source/order/payment/confirm_payment'
-CONFIRM_NOTE_TEMPLATE = 'source/order/note/confirm_note'
+CONFIRM_ORDER_TEMPLATE = 'order/confirm_order'
+CONFIRM_FULFILLMENT_TEMPLATE = 'order/confirm_fulfillment'
+UPDATE_FULFILLMENT_TEMPLATE = 'order/update_fulfillment'
+CONFIRM_PAYMENT_TEMPLATE = 'order/payment/confirm_payment'
+CONFIRM_NOTE_TEMPLATE = 'order/note/confirm_note'
def get_email_context(order_token):
diff --git a/templates/templated_email/source/account/password_reset.email b/templates/templated_email/account/password_reset.email
similarity index 100%
rename from templates/templated_email/source/account/password_reset.email
rename to templates/templated_email/account/password_reset.email
diff --git a/templates/templated_email/compiled/.gitkeep b/templates/templated_email/compiled/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/templates/templated_email/source/dashboard/staff/promote_customer.email b/templates/templated_email/dashboard/staff/promote_customer.email
similarity index 100%
rename from templates/templated_email/source/dashboard/staff/promote_customer.email
rename to templates/templated_email/dashboard/staff/promote_customer.email
diff --git a/templates/templated_email/source/dashboard/staff/set_password.email b/templates/templated_email/dashboard/staff/set_password.email
similarity index 100%
rename from templates/templated_email/source/dashboard/staff/set_password.email
rename to templates/templated_email/dashboard/staff/set_password.email
diff --git a/templates/templated_email/source/order/confirm_fulfillment.email b/templates/templated_email/order/confirm_fulfillment.email
similarity index 100%
rename from templates/templated_email/source/order/confirm_fulfillment.email
rename to templates/templated_email/order/confirm_fulfillment.email
diff --git a/templates/templated_email/source/order/confirm_order.email b/templates/templated_email/order/confirm_order.email
similarity index 100%
rename from templates/templated_email/source/order/confirm_order.email
rename to templates/templated_email/order/confirm_order.email
diff --git a/templates/templated_email/source/order/note/confirm_note.email b/templates/templated_email/order/note/confirm_note.email
similarity index 100%
rename from templates/templated_email/source/order/note/confirm_note.email
rename to templates/templated_email/order/note/confirm_note.email
diff --git a/templates/templated_email/source/order/payment/confirm_payment.email b/templates/templated_email/order/payment/confirm_payment.email
similarity index 100%
rename from templates/templated_email/source/order/payment/confirm_payment.email
rename to templates/templated_email/order/payment/confirm_payment.email
diff --git a/templates/templated_email/source/order/update_fulfillment.email b/templates/templated_email/order/update_fulfillment.email
similarity index 100%
rename from templates/templated_email/source/order/update_fulfillment.email
rename to templates/templated_email/order/update_fulfillment.email
diff --git a/templates/templated_email/source/order/confirm_fulfillment.mjml b/templates/templated_email/source/confirm_fulfillment.mjml
similarity index 89%
rename from templates/templated_email/source/order/confirm_fulfillment.mjml
rename to templates/templated_email/source/confirm_fulfillment.mjml
index 4afe3a530d..edcf1e98bd 100644
--- a/templates/templated_email/source/order/confirm_fulfillment.mjml
+++ b/templates/templated_email/source/confirm_fulfillment.mjml
@@ -1,6 +1,6 @@
<mjml>
<mj-head>
- <mj-include path="../shared/styles" />
+ <mj-include path="./shared/styles" />
</mj-head>
<mj-body>
<mj-container>
@@ -11,7 +11,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../shared/header" />
+ <mj-include path="./shared/header" />
<mj-section>
<mj-column>
<mj-text font-size="16px">
@@ -30,7 +30,7 @@
</mj-column>
</mj-section>
<mj-include path="./partials/_fulfillment_lines" />
- <mj-include path="../shared/footer" />
+ <mj-include path="./shared/footer" />
</mj-container>
</mj-body>
</mjml>
diff --git a/templates/templated_email/source/order/note/confirm_note.mjml b/templates/templated_email/source/confirm_note.mjml
similarity index 84%
rename from templates/templated_email/source/order/note/confirm_note.mjml
rename to templates/templated_email/source/confirm_note.mjml
index 43d5b2d55b..2ac9ba2754 100644
--- a/templates/templated_email/source/order/note/confirm_note.mjml
+++ b/templates/templated_email/source/confirm_note.mjml
@@ -1,6 +1,6 @@
<mjml>
<mj-head>
- <mj-include path="../../shared/styles" />
+ <mj-include path="./shared/styles" />
</mj-head>
<mj-body>
<mj-container>
@@ -11,7 +11,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../../shared/header" />
+ <mj-include path="./shared/header" />
<mj-section>
<mj-column>
<mj-text font-size="16px">
@@ -24,7 +24,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../../shared/footer" />
+ <mj-include path="./shared/footer" />
</mj-container>
</mj-body>
</mjml>
diff --git a/templates/templated_email/source/order/confirm_order.mjml b/templates/templated_email/source/confirm_order.mjml
similarity index 93%
rename from templates/templated_email/source/order/confirm_order.mjml
rename to templates/templated_email/source/confirm_order.mjml
index 954cbcd68f..b89d6881e2 100644
--- a/templates/templated_email/source/order/confirm_order.mjml
+++ b/templates/templated_email/source/confirm_order.mjml
@@ -1,6 +1,6 @@
<mjml>
<mj-head>
- <mj-include path="../shared/styles" />
+ <mj-include path="./shared/styles" />
</mj-head>
<mj-body>
<mj-container>
@@ -12,7 +12,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../shared/header" />
+ <mj-include path="./shared/header" />
<mj-section>
<mj-column>
<mj-text font-size="16px">
@@ -52,7 +52,7 @@
</mj-table>
</mj-column>
</mj-section>
- <mj-include path="../shared/footer" />
+ <mj-include path="./shared/footer" />
</mj-container>
</mj-body>
</mjml>
diff --git a/templates/templated_email/source/order/payment/confirm_payment.mjml b/templates/templated_email/source/confirm_payment.mjml
similarity index 84%
rename from templates/templated_email/source/order/payment/confirm_payment.mjml
rename to templates/templated_email/source/confirm_payment.mjml
index 21aa1a9069..a456deb6b9 100644
--- a/templates/templated_email/source/order/payment/confirm_payment.mjml
+++ b/templates/templated_email/source/confirm_payment.mjml
@@ -1,6 +1,6 @@
<mjml>
<mj-head>
- <mj-include path="../../shared/styles" />
+ <mj-include path="./shared/styles" />
</mj-head>
<mj-body>
<mj-container>
@@ -11,7 +11,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../../shared/header" />
+ <mj-include path="./shared/header" />
<mj-section>
<mj-column>
<mj-text font-size="16px">
@@ -24,7 +24,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../../shared/footer" />
+ <mj-include path="./shared/footer" />
</mj-container>
</mj-body>
</mjml>
diff --git a/templates/templated_email/source/order/partials/_fulfillment_lines.mjml b/templates/templated_email/source/partials/_fulfillment_lines.mjml
similarity index 100%
rename from templates/templated_email/source/order/partials/_fulfillment_lines.mjml
rename to templates/templated_email/source/partials/_fulfillment_lines.mjml
diff --git a/templates/templated_email/source/order/partials/_order_lines.mjml b/templates/templated_email/source/partials/_order_lines.mjml
similarity index 100%
rename from templates/templated_email/source/order/partials/_order_lines.mjml
rename to templates/templated_email/source/partials/_order_lines.mjml
diff --git a/templates/templated_email/source/account/password_reset.mjml b/templates/templated_email/source/password_reset.mjml
similarity index 89%
rename from templates/templated_email/source/account/password_reset.mjml
rename to templates/templated_email/source/password_reset.mjml
index a5019a20ae..0ff91d9008 100644
--- a/templates/templated_email/source/account/password_reset.mjml
+++ b/templates/templated_email/source/password_reset.mjml
@@ -1,6 +1,6 @@
<mjml>
<mj-head>
- <mj-include path="../shared/styles" />
+ <mj-include path="./shared/styles" />
</mj-head>
<mj-body>
<mj-container>
@@ -11,7 +11,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../shared/header" />
+ <mj-include path="./shared/header" />
<mj-section>
<mj-column>
<mj-text font-size="16px">
@@ -30,7 +30,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../shared/footer" />
+ <mj-include path="./shared/footer" />
</mj-container>
</mj-body>
</mjml>
diff --git a/templates/templated_email/source/dashboard/staff/promote_customer.mjml b/templates/templated_email/source/promote_customer.mjml
similarity index 86%
rename from templates/templated_email/source/dashboard/staff/promote_customer.mjml
rename to templates/templated_email/source/promote_customer.mjml
index 0990ce2d3e..d767f19f27 100644
--- a/templates/templated_email/source/dashboard/staff/promote_customer.mjml
+++ b/templates/templated_email/source/promote_customer.mjml
@@ -1,6 +1,6 @@
<mjml>
<mj-head>
- <mj-include path="../../shared/styles" />
+ <mj-include path="./shared/styles" />
</mj-head>
<mj-body>
<mj-container>
@@ -11,7 +11,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../../shared/header" />
+ <mj-include path="./shared/header" />
<mj-section>
<mj-column>
<mj-text font-size="16px">
@@ -25,7 +25,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../../shared/footer" />
+ <mj-include path="./shared/footer" />
</mj-container>
</mj-body>
</mjml>
diff --git a/templates/templated_email/source/dashboard/staff/set_password.mjml b/templates/templated_email/source/set_password.mjml
similarity index 88%
rename from templates/templated_email/source/dashboard/staff/set_password.mjml
rename to templates/templated_email/source/set_password.mjml
index 888fc3eac6..aa3ee224a5 100644
--- a/templates/templated_email/source/dashboard/staff/set_password.mjml
+++ b/templates/templated_email/source/set_password.mjml
@@ -1,6 +1,6 @@
<mjml>
<mj-head>
- <mj-include path="../../shared/styles" />
+ <mj-include path="./shared/styles" />
</mj-head>
<mj-body>
<mj-container>
@@ -11,7 +11,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../../shared/header" />
+ <mj-include path="./shared/header" />
<mj-section>
<mj-column>
<mj-text font-size="16px">
@@ -30,7 +30,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../../shared/footer" />
+ <mj-include path="./shared/footer" />
</mj-container>
</mj-body>
</mjml>
diff --git a/templates/templated_email/source/order/update_fulfillment.mjml b/templates/templated_email/source/update_fulfillment.mjml
similarity index 89%
rename from templates/templated_email/source/order/update_fulfillment.mjml
rename to templates/templated_email/source/update_fulfillment.mjml
index f59fbdcb17..653cde1ad8 100644
--- a/templates/templated_email/source/order/update_fulfillment.mjml
+++ b/templates/templated_email/source/update_fulfillment.mjml
@@ -1,6 +1,6 @@
<mjml>
<mj-head>
- <mj-include path="../shared/styles" />
+ <mj-include path="./shared/styles" />
</mj-head>
<mj-body>
<mj-container>
@@ -11,7 +11,7 @@
</mj-text>
</mj-column>
</mj-section>
- <mj-include path="../shared/header" />
+ <mj-include path="./shared/header" />
<mj-section>
<mj-column>
<mj-text font-size="16px">
@@ -30,7 +30,7 @@
</mj-column>
</mj-section>
<mj-include path="./partials/_fulfillment_lines" />
- <mj-include path="../shared/footer" />
+ <mj-include path="./shared/footer" />
</mj-container>
</mj-body>
</mjml>
diff --git a/tests/dashboard/test_staff.py b/tests/dashboard/test_staff.py
index adc7db09f2..76639487f0 100644
--- a/tests/dashboard/test_staff.py
+++ b/tests/dashboard/test_staff.py
@@ -105,7 +105,7 @@ def test_send_set_password_email(staff_user, site_settings):
'uid': urlsafe_base64_encode(force_bytes(staff_user.pk)).decode(),
'token': default_token_generator.make_token(staff_user)}
send_templated_mail(
- template_name='source/dashboard/staff/set_password',
+ template_name='dashboard/staff/set_password',
from_email=DEFAULT_FROM_EMAIL,
recipient_list=[staff_user.email],
context=ctx)