diff mbox series

[layerindex-web] layerindex/views.py: tweak from_email

Message ID 20240818220918.2372304-2-tim.orling@konsulko.com
State Accepted, archived
Commit 6747ed3707315a800c99fbb57fd6a35ebb985d4e
Delegated to: Tim Orling
Headers show
Series [layerindex-web] layerindex/views.py: tweak from_email | expand

Commit Message

Tim Orling Aug. 18, 2024, 10:09 p.m. UTC
From: Tim Orling <tim.orling@konsulko.com>

In production, we use settings.DEFAULT_FROM_EMAIL as our primary source
of from_email, rather than settings.SUBMIT_EMAIL_FROM

Default to DEFAULT_FROM_EMAIL if it is not Null, fall back to SUBMIT_EMAIL_FROM

The real consumer (in production) is a Celery task in layerindex/tasks.py

@tasks.task
def send_email(subject, text_content, from_email=settings.DEFAULT_FROM_EMAIL, to_emails=[]):

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 layerindex/views.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/layerindex/views.py b/layerindex/views.py
index c7a1f09..4df2a09 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -1672,7 +1672,7 @@  def email_test_view(request):
         'help_contact': _get_help_contact(),
     }
     subject = '%s: test email' % site_name
-    from_email = settings.SUBMIT_EMAIL_FROM
+    from_email = settings.DEFAULT_FROM_EMAIL if settings.DEFAULT_FROM_EMAIL else settings.SUBMIT_EMAIL_FROM
     to_email = request.user.email
     text_content = plaintext.render(d)
     tasks.send_email.apply_async((subject, text_content, from_email, [to_email]))