From dc5e725fd6dfecc861838c2a4fb1671e5442c13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mih=C3=A1lik?= Date: Wed, 21 Aug 2024 11:20:45 +0200 Subject: [PATCH] Test environment email backend setup (#398) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martin Mihálik --- competition/views.py | 8 ++++---- user/serializers.py | 4 ++-- webstrom/settings.py | 4 ++-- webstrom/settings_test.py | 5 +++++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/competition/views.py b/competition/views.py index 73736e2..f11006e 100644 --- a/competition/views.py +++ b/competition/views.py @@ -42,7 +42,7 @@ rank_results) from personal.models import Profile, School from personal.serializers import ProfileExportSerializer, SchoolSerializer -from webstrom.settings import EMAIL_ALERT, EMAIL_NO_REPLY +from webstrom.settings import EMAIL_ALERT # pylint: disable=unused-argument @@ -154,7 +154,7 @@ def publish(self, request, pk=None): send_mail( 'Zverejnený komentár', render_to_string('competition/emails/comment_published.txt'), - EMAIL_NO_REPLY, + None, [comment.posted_by.email], ) @@ -171,7 +171,7 @@ def hide(self, request, pk=None): send_mail( 'Skrytý komentár', render_to_string('competition/emails/comment_hidden.txt'), - EMAIL_NO_REPLY, + None, [comment.posted_by.email], ) @@ -231,7 +231,7 @@ def add_comment(self, request, pk=None): send_mail( 'Nový komentár', render_to_string('competition/emails/comment_added.txt'), - EMAIL_NO_REPLY, + None, [EMAIL_ALERT], ) diff --git a/user/serializers.py b/user/serializers.py index c4d08fe..2dcd116 100644 --- a/user/serializers.py +++ b/user/serializers.py @@ -12,7 +12,7 @@ from personal.models import Profile from personal.serializers import ProfileCreateSerializer from user.models import TokenModel -from webstrom.settings import EMAIL_ALERT, EMAIL_NO_REPLY +from webstrom.settings import EMAIL_ALERT def reset_password_url_generator(request, user, temp_key): @@ -172,7 +172,7 @@ def handle_other_school(self, school): 'school_info': school_info }, ), - EMAIL_NO_REPLY, + None, [EMAIL_ALERT] ) diff --git a/webstrom/settings.py b/webstrom/settings.py index 894772e..5ffb1de 100644 --- a/webstrom/settings.py +++ b/webstrom/settings.py @@ -188,7 +188,7 @@ EMAIL_VERIFICATION_TIMEOUT = 86400 -MANAGERS = [('Web', 'web@strom.sk'), ] +MANAGERS = [('Web', 'webmaster@strom.sk'), ] -EMAIL_NO_REPLY = 'no-reply@strom.sk' # z tade sa odosielaju maily +DEFAULT_FROM_EMAIL = 'noreply@strom.sk' # z tade sa odosielaju maily EMAIL_ALERT = 'alert-email-address@strom.sk' # tu sa prijimaju maily diff --git a/webstrom/settings_test.py b/webstrom/settings_test.py index 65d76d7..7ccf4f3 100644 --- a/webstrom/settings_test.py +++ b/webstrom/settings_test.py @@ -21,3 +21,8 @@ } EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" + +EMAIL_HOST = "smtp-relay.gmail.com" +EMAIL_PORT = 587 +EMAIL_USE_TLS = True +EMAIL_TIMEOUT = 10