Skip to content

Commit befcb8d

Browse files
authored
Merge pull request #2095 from codalab/server_email
EMAIL - replaced `DEFAULT_FROM_EMAIL` by `SERVER_EMAIL`
2 parents af6951a + 8f5aabf commit befcb8d

6 files changed

Lines changed: 4 additions & 8 deletions

File tree

.env_sample

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ SELENIUM_HOSTNAME=selenium
4242
#EMAIL_HOST_PASSWORD=pass
4343
#EMAIL_PORT=587
4444
#EMAIL_USE_TLS=True
45-
#DEFAULT_FROM_EMAIL="Codabench <noreply@example.com>"
4645
#SERVER_EMAIL=noreply@example.com
4746

4847
# Contact Email

src/apps/forums/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def send_mail(context=None, from_email=None, html_file=None, text_file=None, sub
1515
:param subject: Email's subject.
1616
:param to_email: Recipient's email.
1717
"""
18-
from_email = from_email if from_email else settings.DEFAULT_FROM_EMAIL
18+
from_email = from_email if from_email else settings.SERVER_EMAIL
1919

2020
context["site"] = Site.objects.get_current()
2121

src/apps/profiles/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def send_mail(context=None, from_email=None, html_file=None, text_file=None, sub
1515
:param subject: Email's subject.
1616
:param to_email: Recipient's email.
1717
"""
18-
from_email = from_email if from_email else settings.DEFAULT_FROM_EMAIL
18+
from_email = from_email if from_email else settings.SERVER_EMAIL
1919

2020
context["site"] = Site.objects.get_current()
2121

src/apps/profiles/views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ class CustomPasswordResetView(auth_views.PasswordResetView):
347347
We have to use app:view_name syntax in templates like " {% url 'accounts:password_reset_confirm'%} "
348348
Therefore we need to tell this view to find the right success_url with that syntax or django won't be
349349
able to find the view.
350-
3. from_email: We want to use SERVER_EMAIL already set in the .env
351350
# The other commented sections are the defaults for other attributes in auth_views.PasswordResetView.
352351
They are in here in case someone wants to customize in the future. All attributes show up in the order
353352
shown in the docs.
@@ -358,7 +357,6 @@ class CustomPasswordResetView(auth_views.PasswordResetView):
358357
# subject_template_name = '' # Defaults to registration/password_reset_subject.txt if not supplied.
359358
# token_generator = '' # This will default to default_token_generator, it’s an instance of django.contrib.auth.tokens.PasswordResetTokenGenerator.
360359
success_url = django.urls.reverse_lazy("accounts:password_reset_done")
361-
from_email = settings.SERVER_EMAIL
362360

363361

364362
class CustomPasswordResetConfirmView(auth_views.PasswordResetConfirmView):

src/settings/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ def setup_celery_logging(**kwargs):
449449
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
450450
EMAIL_PORT = os.environ.get('EMAIL_PORT', 587)
451451
EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS', True)
452-
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', 'Codabench <noreply@codabench.org>')
453452
SERVER_EMAIL = os.environ.get('SERVER_EMAIL', 'noreply@codabench.org')
454453

455454
CONTACT_EMAIL = os.environ.get('CONTACT_EMAIL', 'info@codabench.org')

src/utils/email.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def codalab_send_mail(context_data, to_email, html_file, text_file, subject, from_email=None):
10-
from_email = from_email if from_email else settings.DEFAULT_FROM_EMAIL
10+
from_email = from_email if from_email else settings.SERVER_EMAIL
1111

1212
context_data["site"] = Site.objects.get_current()
1313

@@ -40,7 +40,7 @@ def sanitize(content):
4040

4141

4242
def codalab_send_markdown_email(subject, markdown_content, recipient_list, from_email=None):
43-
from_email = from_email if from_email else settings.DEFAULT_FROM_EMAIL
43+
from_email = from_email if from_email else settings.SERVER_EMAIL
4444
html_message = markdown.markdown(markdown_content)
4545
# message = sanitize(markdown_content)
4646
# html_message = sanitize(markdown.markdown(message))

0 commit comments

Comments
 (0)