layerindex/views.py: tweak from_email

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>
This commit is contained in:
Tim Orling 2024-08-18 14:07:40 -07:00
parent c4035f018f
commit 6747ed3707

View File

@ -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]))