From 8f5aabf9961f201b6a2f21a606cad647f4f00112 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Tue, 23 Dec 2025 19:48:41 +0500 Subject: [PATCH] replaced DEFAULT_FROM_EMAIL by SERVER_EMAIL --- .env_sample | 1 - src/apps/forums/helpers.py | 2 +- src/apps/profiles/helpers.py | 2 +- src/apps/profiles/views.py | 2 -- src/settings/base.py | 1 - src/utils/email.py | 4 ++-- 6 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.env_sample b/.env_sample index 8d8629a3c..027616fa8 100644 --- a/.env_sample +++ b/.env_sample @@ -42,7 +42,6 @@ SELENIUM_HOSTNAME=selenium #EMAIL_HOST_PASSWORD=pass #EMAIL_PORT=587 #EMAIL_USE_TLS=True -#DEFAULT_FROM_EMAIL="Codabench " #SERVER_EMAIL=noreply@example.com # Contact Email diff --git a/src/apps/forums/helpers.py b/src/apps/forums/helpers.py index 63ae2699a..bb85f788e 100644 --- a/src/apps/forums/helpers.py +++ b/src/apps/forums/helpers.py @@ -15,7 +15,7 @@ def send_mail(context=None, from_email=None, html_file=None, text_file=None, sub :param subject: Email's subject. :param to_email: Recipient's email. """ - from_email = from_email if from_email else settings.DEFAULT_FROM_EMAIL + from_email = from_email if from_email else settings.SERVER_EMAIL context["site"] = Site.objects.get_current() diff --git a/src/apps/profiles/helpers.py b/src/apps/profiles/helpers.py index 63ae2699a..bb85f788e 100644 --- a/src/apps/profiles/helpers.py +++ b/src/apps/profiles/helpers.py @@ -15,7 +15,7 @@ def send_mail(context=None, from_email=None, html_file=None, text_file=None, sub :param subject: Email's subject. :param to_email: Recipient's email. """ - from_email = from_email if from_email else settings.DEFAULT_FROM_EMAIL + from_email = from_email if from_email else settings.SERVER_EMAIL context["site"] = Site.objects.get_current() diff --git a/src/apps/profiles/views.py b/src/apps/profiles/views.py index 333a96e15..946a93a16 100644 --- a/src/apps/profiles/views.py +++ b/src/apps/profiles/views.py @@ -347,7 +347,6 @@ class CustomPasswordResetView(auth_views.PasswordResetView): We have to use app:view_name syntax in templates like " {% url 'accounts:password_reset_confirm'%} " Therefore we need to tell this view to find the right success_url with that syntax or django won't be able to find the view. - 3. from_email: We want to use SERVER_EMAIL already set in the .env # The other commented sections are the defaults for other attributes in auth_views.PasswordResetView. They are in here in case someone wants to customize in the future. All attributes show up in the order shown in the docs. @@ -358,7 +357,6 @@ class CustomPasswordResetView(auth_views.PasswordResetView): # subject_template_name = '' # Defaults to registration/password_reset_subject.txt if not supplied. # token_generator = '' # This will default to default_token_generator, it’s an instance of django.contrib.auth.tokens.PasswordResetTokenGenerator. success_url = django.urls.reverse_lazy("accounts:password_reset_done") - from_email = settings.SERVER_EMAIL class CustomPasswordResetConfirmView(auth_views.PasswordResetConfirmView): diff --git a/src/settings/base.py b/src/settings/base.py index 505329d73..78bdfa206 100644 --- a/src/settings/base.py +++ b/src/settings/base.py @@ -449,7 +449,6 @@ def setup_celery_logging(**kwargs): EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD') EMAIL_PORT = os.environ.get('EMAIL_PORT', 587) EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS', True) -DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', 'Codabench ') SERVER_EMAIL = os.environ.get('SERVER_EMAIL', 'noreply@codabench.org') CONTACT_EMAIL = os.environ.get('CONTACT_EMAIL', 'info@codabench.org') diff --git a/src/utils/email.py b/src/utils/email.py index 846a5edbc..3969452d5 100644 --- a/src/utils/email.py +++ b/src/utils/email.py @@ -7,7 +7,7 @@ def codalab_send_mail(context_data, to_email, html_file, text_file, subject, from_email=None): - from_email = from_email if from_email else settings.DEFAULT_FROM_EMAIL + from_email = from_email if from_email else settings.SERVER_EMAIL context_data["site"] = Site.objects.get_current() @@ -40,7 +40,7 @@ def sanitize(content): def codalab_send_markdown_email(subject, markdown_content, recipient_list, from_email=None): - from_email = from_email if from_email else settings.DEFAULT_FROM_EMAIL + from_email = from_email if from_email else settings.SERVER_EMAIL html_message = markdown.markdown(markdown_content) # message = sanitize(markdown_content) # html_message = sanitize(markdown.markdown(message))