Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove gluing urls in templates
TOMEKcd67401b7dbe
diff --git a/saleor/account/emails.py b/saleor/account/emails.pyindex e5646793f8..ada50ab9c1 100644--- a/saleor/account/emails.py+++ b/saleor/account/emails.py@@ -24,9 +24,13 @@ def send_password_reset_email(context, recipient):@shared_taskdef send_account_delete_confirmation_email(token, recipient_email):site = Site.objects.get_current()+ absolute_url = build_absolute_uri(location=None)delete_url = build_absolute_uri(reverse('account:delete-confirm', kwargs={'token': token}))- ctx = {'site_name': site.name, 'domain': site.domain, 'url': delete_url}+ ctx = {+ 'site_name': site.name,+ 'absolute_url': absolute_url,+ 'url': delete_url}send_templated_mail(template_name='account/account_delete',from_email=settings.DEFAULT_FROM_EMAIL,diff --git a/saleor/dashboard/emails.py b/saleor/dashboard/emails.pyindex 266c7f6a72..752d19a650 100644--- a/saleor/dashboard/emails.py+++ b/saleor/dashboard/emails.py@@ -13,9 +13,9 @@ from ..core.utils import build_absolute_uri@shared_taskdef send_set_password_email(staff):site = Site.objects.get_current()+ absolute_url = build_absolute_uri(location=None)ctx = {- 'protocol': 'https' if settings.ENABLE_SSL else 'http',- 'domain': site.domain,+ 'absolute_url': absolute_url,'site_name': site.name,'uid': urlsafe_base64_encode(force_bytes(staff.pk)).decode(),'token': default_token_generator.make_token(staff)}@@ -29,9 +29,9 @@ def send_set_password_email(staff):@shared_taskdef send_promote_customer_to_staff_email(staff):site = Site.objects.get_current()+ absolute_url = build_absolute_uri(location=None)ctx = {- 'protocol': 'https' if settings.ENABLE_SSL else 'http',- 'domain': site.domain,+ 'absolute_url': absolute_url,'url': build_absolute_uri(reverse('dashboard:index')),'site_name': site.name}send_templated_mail(diff --git a/saleor/order/emails.py b/saleor/order/emails.pyindex 521d2c3d58..44aa2ac0c9 100644--- a/saleor/order/emails.py+++ b/saleor/order/emails.py@@ -18,12 +18,12 @@ CONFIRM_NOTE_TEMPLATE = 'order/note/confirm_note'def get_email_context(order_token):"""Prepares context required for email template rendering."""site = Site.objects.get_current()+ absolute_url = build_absolute_uri(location=None)order_url = build_absolute_uri(reverse('order:details', kwargs={'token': order_token}))ctx = {- 'protocol': 'https' if settings.ENABLE_SSL else 'http','site_name': site.name,- 'domain': site.domain,+ 'absolute_url': absolute_url,'url': order_url}return ctxdiff --git a/templates/templated_email/account/account_delete.email b/templates/templated_email/account/account_delete.emailindex aa640ac19c..f94a07e231 100644--- a/templates/templated_email/account/account_delete.email+++ b/templates/templated_email/account/account_delete.email@@ -8,7 +8,7 @@{% blocktrans context "Account delete reset e-mail text" %}Hi!-You're receiving this e-mail because you or someone else has requested a deletion of your user account at {{ domain }}.+You're receiving this e-mail because you or someone else has requested a deletion of your user account at {{ absolute_url }}.Click the link below to delete your account.Please note that this action is permanent and cannot be reversed.diff --git a/templates/templated_email/account/password_reset.email b/templates/templated_email/account/password_reset.emailindex 56aad51e0e..0129f03ac3 100644--- a/templates/templated_email/account/password_reset.email+++ b/templates/templated_email/account/password_reset.email@@ -8,11 +8,11 @@{% blocktrans context "Password reset e-mail text" %}Hi!-You're receiving this e-mail because you or someone else has requested a password for your user account at {{ domain }}.+You're receiving this e-mail because you or someone else has requested a password for your user account at {{ absolute_url }}.It can be safely ignored if you did not request a password reset. Click the link below to reset your password.{% endblocktrans %}-{{ protocol}}://{{ domain }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}+{{ absolute_url }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}This is an automatically generated email, please do not reply.diff --git a/templates/templated_email/dashboard/staff/set_password.email b/templates/templated_email/dashboard/staff/set_password.emailindex 9ce9a61e28..bde114e30f 100644--- a/templates/templated_email/dashboard/staff/set_password.email+++ b/templates/templated_email/dashboard/staff/set_password.email@@ -5,11 +5,11 @@{% blocktrans context "Set password for staff member e-mail text" %}Hi!-You're receiving this e-mail because you have to set password for your staff member account at {{ domain }}.+You're receiving this e-mail because you have to set password for your staff member account at {{ absolute_url }}.Click the link below to reset your password.{% endblocktrans %}-{{ protocol}}://{{ domain }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}+{{ absolute_url }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}{% blocktrans context "Set password for staff member e-mail text" %}This is an automatically generated email, please do not reply.diff --git a/templates/templated_email/source/password_reset.mjml b/templates/templated_email/source/password_reset.mjmlindex fc96277631..7c30067814 100644--- a/templates/templated_email/source/password_reset.mjml+++ b/templates/templated_email/source/password_reset.mjml@@ -14,13 +14,13 @@</mj-text><mj-text>{% blocktrans trimmed context "Password reset e-mail text" %}- You're receiving this e-mail because you or someone else has requested a password for your user account at {{ domain }}.<br/>+ You're receiving this e-mail because you or someone else has requested a password for your user account at {{ absolute_url }}.<br/>It can be safely ignored if you did not request a password reset. Click the link below to reset your password.{% endblocktrans %}</mj-text><mj-text>- <a href="{{ protocol}}://{{ domain }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}">- {{ protocol}}://{{ domain }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}+ <a href="{{ absolute_url }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}">+ {{ absolute_url }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}</a></mj-text></mj-column>diff --git a/templates/templated_email/source/promote_customer.mjml b/templates/templated_email/source/promote_customer.mjmlindex b6eb8bc37b..05c8ea2b33 100644--- a/templates/templated_email/source/promote_customer.mjml+++ b/templates/templated_email/source/promote_customer.mjml@@ -14,7 +14,7 @@</mj-text><mj-text>{% blocktrans trimmed context "Promote customer to staff member confirmation e-mail text" %}- You're receiving this e-mail because you have been promoted to staff member at {{ domain }}.<br/>+ You're receiving this e-mail because you have been promoted to staff member at {{ absolute_url }}.<br/>To access dashboard please visit: <a href="{{ url }}">{{ url }}</a>{% endblocktrans %}</mj-text>diff --git a/templates/templated_email/source/set_password.mjml b/templates/templated_email/source/set_password.mjmlindex ee426d4d35..fae820f105 100644--- a/templates/templated_email/source/set_password.mjml+++ b/templates/templated_email/source/set_password.mjml@@ -14,13 +14,13 @@</mj-text><mj-text>{% blocktrans trimmed context "Set password for staff member e-mail text" %}- You're receiving this e-mail because you have to set password for your staff member account at {{ domain }}.<br/>+ You're receiving this e-mail because you have to set password for your staff member account at {{ absolute_url }}.<br/>Click the link below to set up your password.{% endblocktrans %}</mj-text><mj-text>- <a href="{{ protocol}}://{{ domain }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}">- {{ protocol}}://{{ domain }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}+ <a href="{{ absolute_url }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}">+ {{ absolute_url }}{% url 'account:reset-password-confirm' uidb64=uid token=token %}</a></mj-text></mj-column>diff --git a/templates/templated_email/source/shared/header.mjml b/templates/templated_email/source/shared/header.mjmlindex 3982ac523d..57bfd37c55 100644--- a/templates/templated_email/source/shared/header.mjml+++ b/templates/templated_email/source/shared/header.mjml@@ -3,6 +3,6 @@</mj-raw><mj-section><mj-column>- <mj-image src="{{ protocol}}://{{ domain }}{% static 'images/logo-document.svg' %}" height="38px" width="176px"/>+ <mj-image src="{{ absolute_url }}{% static 'images/logo-document.svg' %}" height="38px" width="176px"/></mj-column></mj-section>diff --git a/tests/dashboard/test_staff.py b/tests/dashboard/test_staff.pyindex 64d2160e10..98d7a7c571 100644--- a/tests/dashboard/test_staff.py+++ b/tests/dashboard/test_staff.py@@ -97,9 +97,9 @@ def test_staff_create_email_with_set_link_password(admin_client):def test_send_set_password_email(staff_user, site_settings):site = site_settings.site+ absolute_url = build_absolute_uri(location=None)ctx = {- 'protocol': 'http',- 'domain': site.domain,+ 'absolute_url': absolute_url,'site_name': site.name,'uid': urlsafe_base64_encode(force_bytes(staff_user.pk)).decode(),'token': default_token_generator.make_token(staff_user)}diff --git a/tests/test_emails.py b/tests/test_emails.pyindex 548ddea961..6c7d14b2e6 100644--- a/tests/test_emails.py+++ b/tests/test_emails.py@@ -11,12 +11,12 @@ from saleor.core.utils import build_absolute_uridef test_get_email_context(order, site_settings):site = site_settings.site+ absolute_url = build_absolute_uri(location=None)order_url = build_absolute_uri(reverse('order:details', kwargs={'token': order.token}))proper_context = {- 'protocol': 'https' if settings.ENABLE_SSL else 'http','site_name': site.name,- 'domain': site.domain,+ 'absolute_url': absolute_url,'url': order_url}received_context = emails.get_email_context(order.token)