From 542ccbac7a68828218f39b0ceefd319c8aa0dd25 Mon Sep 17 00:00:00 2001 From: manortbla Date: Sat, 13 Apr 2024 11:12:19 +0200 Subject: [PATCH 1/5] email 'es' --- .../templates/registration/activation_email.html | 14 ++++++++++++++ src/settings.py | 3 +++ 2 files changed, 17 insertions(+) create mode 100644 nexong/templates/registration/activation_email.html diff --git a/nexong/templates/registration/activation_email.html b/nexong/templates/registration/activation_email.html new file mode 100644 index 0000000..c3a8c58 --- /dev/null +++ b/nexong/templates/registration/activation_email.html @@ -0,0 +1,14 @@ + + + + + Activación de cuenta + + +

¡Gracias por registrarte en nuestra web!

+

Por favor, haz clic en el siguiente enlace para activar tu cuenta:

+

{{ protocol }}://{{ domain }}{{ url }}

+

¡Gracias por usar nuestro sitio!

+

El equipo de {{ domain }}

+ + diff --git a/src/settings.py b/src/settings.py index c4a6894..8469e46 100644 --- a/src/settings.py +++ b/src/settings.py @@ -195,6 +195,9 @@ }, "SOCIAL_AUTH_TOKEN_STRATEGY": "djoser.social.token.jwt.TokenStrategy", "SOCIAL_AUTH_ALLOWED_REDIRECT_URIS": white_list, + "Email":{ + "activation":"registration/activation_email.html", + }, } SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = config("GOOGLE_OAUTH2_KEY") From e7ed220e7df6ffb2c2324b05ef2adf9a6f5bf0a4 Mon Sep 17 00:00:00 2001 From: manortbla Date: Sat, 13 Apr 2024 12:32:52 +0200 Subject: [PATCH 2/5] fix: redirecto to frontend login --- nexong/api/Authentication/views.py | 2 +- nexong/templates/{registration => }/activation_email.html | 0 src/settings.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename nexong/templates/{registration => }/activation_email.html (100%) diff --git a/nexong/api/Authentication/views.py b/nexong/api/Authentication/views.py index 1a09024..dad8a25 100644 --- a/nexong/api/Authentication/views.py +++ b/nexong/api/Authentication/views.py @@ -159,7 +159,7 @@ def get(self, request, *args, **kwargs): user.is_enabled = True user.is_active = True user.save() - return redirect(reverse("activation_success")) + return redirect("http://127.0.0.1:3000/iniciar-sesion/") else: return Response( {"detail": "Token not valid"}, diff --git a/nexong/templates/registration/activation_email.html b/nexong/templates/activation_email.html similarity index 100% rename from nexong/templates/registration/activation_email.html rename to nexong/templates/activation_email.html diff --git a/src/settings.py b/src/settings.py index 8469e46..160329e 100644 --- a/src/settings.py +++ b/src/settings.py @@ -196,7 +196,7 @@ "SOCIAL_AUTH_TOKEN_STRATEGY": "djoser.social.token.jwt.TokenStrategy", "SOCIAL_AUTH_ALLOWED_REDIRECT_URIS": white_list, "Email":{ - "activation":"registration/activation_email.html", + "activation":"templates/activation_email.html", }, } From ba9d6d7f1c056b25b777d27ef725a0e557c3e439 Mon Sep 17 00:00:00 2001 From: manortbla Date: Sat, 13 Apr 2024 15:39:03 +0200 Subject: [PATCH 3/5] bug --- nexong/templates/activation_email.html | 14 -------------- src/settings.py | 3 --- 2 files changed, 17 deletions(-) delete mode 100644 nexong/templates/activation_email.html diff --git a/nexong/templates/activation_email.html b/nexong/templates/activation_email.html deleted file mode 100644 index c3a8c58..0000000 --- a/nexong/templates/activation_email.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Activación de cuenta - - -

¡Gracias por registrarte en nuestra web!

-

Por favor, haz clic en el siguiente enlace para activar tu cuenta:

-

{{ protocol }}://{{ domain }}{{ url }}

-

¡Gracias por usar nuestro sitio!

-

El equipo de {{ domain }}

- - diff --git a/src/settings.py b/src/settings.py index 160329e..c4a6894 100644 --- a/src/settings.py +++ b/src/settings.py @@ -195,9 +195,6 @@ }, "SOCIAL_AUTH_TOKEN_STRATEGY": "djoser.social.token.jwt.TokenStrategy", "SOCIAL_AUTH_ALLOWED_REDIRECT_URIS": white_list, - "Email":{ - "activation":"templates/activation_email.html", - }, } SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = config("GOOGLE_OAUTH2_KEY") From 72195ad6339ddb7c99662661cc2818e598471d9d Mon Sep 17 00:00:00 2001 From: manortbla Date: Wed, 17 Apr 2024 13:11:32 +0200 Subject: [PATCH 4/5] feat: email fixed --- nexong/email.py | 7 +++++++ nexong/templates/account/activation.html | 15 +++++++++++++++ src/settings.py | 3 +++ 3 files changed, 25 insertions(+) create mode 100644 nexong/email.py create mode 100644 nexong/templates/account/activation.html diff --git a/nexong/email.py b/nexong/email.py new file mode 100644 index 0000000..6b1cebc --- /dev/null +++ b/nexong/email.py @@ -0,0 +1,7 @@ +from djoser import email + + +class ActivationEmail(email.ActivationEmail): + template_name = 'account/activation.html' + + diff --git a/nexong/templates/account/activation.html b/nexong/templates/account/activation.html new file mode 100644 index 0000000..322c7bf --- /dev/null +++ b/nexong/templates/account/activation.html @@ -0,0 +1,15 @@ +{% load i18n %} + +{% block subject %} +{% blocktrans %}Activación de cuenta en {{ site_name }}{% endblocktrans %} +{% endblock subject %} + + +{% block html_body %} +

{% blocktrans %} +Estás recibiendo este correo porque necesitas finalizar el proceso de activación de tu cuenta en {{ protocol }}://{{ domain }}/{{ url|safe }} +{% endblocktrans %}

+

Al pulsar el botón, se activará su cuenta y será redirigido a la página de inicio de sesión:

+

Activar cuenta

+ +{% endblock html_body %} diff --git a/src/settings.py b/src/settings.py index c4a6894..d346833 100644 --- a/src/settings.py +++ b/src/settings.py @@ -195,6 +195,9 @@ }, "SOCIAL_AUTH_TOKEN_STRATEGY": "djoser.social.token.jwt.TokenStrategy", "SOCIAL_AUTH_ALLOWED_REDIRECT_URIS": white_list, + "EMAIL": { + "activation": "nexong.email.ActivationEmail", + }, } SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = config("GOOGLE_OAUTH2_KEY") From d860fc58440b35dbe7e5df8ee3bca43b48d78498 Mon Sep 17 00:00:00 2001 From: manortbla Date: Wed, 17 Apr 2024 11:12:08 +0000 Subject: [PATCH 5/5] refactor: Format code with Black --- nexong/email.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nexong/email.py b/nexong/email.py index 6b1cebc..be24ee5 100644 --- a/nexong/email.py +++ b/nexong/email.py @@ -2,6 +2,4 @@ class ActivationEmail(email.ActivationEmail): - template_name = 'account/activation.html' - - + template_name = "account/activation.html"