From 373e89246317fb7efa277d82803556c721055382 Mon Sep 17 00:00:00 2001
From: Diego Calvo
Date: Tue, 30 Mar 2021 14:19:16 +0200
Subject: [PATCH] Fixed emails
---
back_latienda/settings/development.py | 9 +++
core/utils.py | 7 ++-
templates/email_verification.html | 10 ++--
.../purchase_contact_confirmation_v2.html | 56 ++++++++++++-------
templates/purchase_notification_v2.html | 31 ++++++----
5 files changed, 74 insertions(+), 39 deletions(-)
diff --git a/back_latienda/settings/development.py b/back_latienda/settings/development.py
index af1f405..c8b6f9d 100644
--- a/back_latienda/settings/development.py
+++ b/back_latienda/settings/development.py
@@ -52,6 +52,15 @@ SIMPLE_JWT = {
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+# For testing emails
+# https://medium.com/@_christopher/how-to-send-emails-with-python-django-through-google-smtp-server-for-free-22ea6ea0fb8e
+# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
+# EMAIL_HOST = 'smtp.gmail.com'
+# EMAIL_USE_TLS = True
+# EMAIL_PORT = 587
+# EMAIL_HOST_USER = '' # your email account
+# EMAIL_HOST_PASSWORD = '' #your password
+
# disable web interface for REST backend
# REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] = ('rest_framework.renderers.JSONRenderer',)
diff --git a/core/utils.py b/core/utils.py
index ad0f96e..ae85804 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -71,12 +71,13 @@ def create_admin_user(email, password):
def send_verification_email(request, user):
try:
current_site = get_current_site(request)
+ uid = urlsafe_base64_encode(force_bytes(user.pk))
+ token = account_activation_token.make_token(user)
+ verification_url = 'https://' + current_site.domain + '/activate/' + uid + '/' + token
subject = 'Activa Tu Cuenta'
message = render_to_string('email_verification.html', {
'user': user,
- 'domain': current_site.domain,
- 'uid': urlsafe_base64_encode(force_bytes(user.pk)),
- 'token': account_activation_token.make_token(user),
+ 'verification_url': verification_url
})
email = EmailMessage(
subject, message, to=[user.email]
diff --git a/templates/email_verification.html b/templates/email_verification.html
index db8a15e..43d57b2 100644
--- a/templates/email_verification.html
+++ b/templates/email_verification.html
@@ -209,7 +209,7 @@
height="auto"
width="25"
align="left"
- src="https://latienda.coop/_nuxt/img/latienda-logo.3e53761.svg"
+ src="https://latienda.coop/_nuxt/img/latienda-logo.dea6549.png"
style="
border: none;
display: block;
@@ -485,12 +485,12 @@
"
>
Hola {{ user.full_name }},
-
+
Por favor, verifica tu
registro en LaTiendaCOOP
- haciendo click AQUĆ
+ haciendo click en el siguiente enlace:
+
+ {{verification_url}}
diff --git a/templates/purchase_contact_confirmation_v2.html b/templates/purchase_contact_confirmation_v2.html
index 6cadb53..2075380 100644
--- a/templates/purchase_contact_confirmation_v2.html
+++ b/templates/purchase_contact_confirmation_v2.html
@@ -430,21 +430,11 @@
href="https://latienda.coop/productos/{{product.id}}"
target="_blank"
>
+ {% if product.image %}
+ {% else %}
+
+ {% endif %}
@@ -729,18 +736,28 @@
+ {% if company.logo %}
+ {% else %}
+
+ {% endif %}
|
diff --git a/templates/purchase_notification_v2.html b/templates/purchase_notification_v2.html
index 0646e93..205d2d1 100755
--- a/templates/purchase_notification_v2.html
+++ b/templates/purchase_notification_v2.html
@@ -426,21 +426,11 @@
href="https://latienda.coop/productos/{{product.id}}"
target="_blank"
>
+ {% if product.image %}
+ {% else %}
+
+ {% endif %}
@@ -941,7 +948,7 @@
>