Skip to content

Commit

Permalink
[Merge] Staging->Develop (#3866)
Browse files Browse the repository at this point in the history
* tweaks (#3856)

* fix filtering by rdi

* [200749] Add email sender settings (#3865)

---------

Co-authored-by: Jan Romaniak <[email protected]>
Co-authored-by: Domenico <[email protected]>
Co-authored-by: Jan Romaniak <[email protected]>
  • Loading branch information
4 people authored May 14, 2024
1 parent 49c2832 commit 1efc38d
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ EMAIL_BACKEND="django.core.mail.backends.console.EmailBackend"
EMAIL_HOST=TBD
EMAIL_HOST_USER=TBD
EMAIL_HOST_PASSWORD=TBD

MAILJET_API_KEY=
MAILJET_SECRET_KEY=
CATCH_ALL_EMAIL=
DEFAULT_EMAIL_DISPLAY=
DEFAULT_EMAIL=

MAP_BOX_KEY=MAP_BOX_KEY_HERE
DJANGO_ALLOWED_HOST=127.0.0.1 # Optional, defaults to localhost
HCT_MIS_FRONTEND_HOST=127.0.0.1:8080 # Optional, defaults to DJANGO_ALLOWED_HOST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@
"choices": [],
"associated_with": _HOUSEHOLD,
"xlsx_field": "registration_data_import",
"scope": [Scope.TARGETING],
"scope": [Scope.TARGETING, Scope.XLSX_PEOPLE],
},
{
"id": "e4aa9cdf-2c9e-4e22-9928-2b63a6ea4ef0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def _get_expected_email_body(self, context: dict) -> str:
{
"Messages": [
{
"From": {"Email": settings.EMAIL_HOST_USER, "Name": settings.DEFAULT_FROM_EMAIL},
"From": {"Email": settings.DEFAULT_EMAIL, "Name": settings.DEFAULT_EMAIL_DISPLAY},
"Subject": f"[test] Individual IBANs xlsx [{context['upload_file_id']}] update result",
"To": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_email_body_for_generate_report(self, mocked_requests_post: Any) -> None
{
"Messages": [
{
"From": {"Email": settings.EMAIL_HOST_USER, "Name": settings.DEFAULT_FROM_EMAIL},
"From": {"Email": settings.DEFAULT_EMAIL, "Name": settings.DEFAULT_EMAIL_DISPLAY},
"Subject": "[test] HOPE report generated",
"To": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __getitem__(self, key: int) -> list:
{
"Messages": [
{
"From": {"Email": settings.EMAIL_HOST_USER, "Name": settings.DEFAULT_FROM_EMAIL},
"From": {"Email": settings.DEFAULT_EMAIL, "Name": settings.DEFAULT_EMAIL_DISPLAY},
"Subject": f"[test] {subject}",
"To": [{"Email": "[email protected]"}],
"Cc": [{"Email": settings.SANCTION_LIST_CC_MAIL}],
Expand Down
4 changes: 2 additions & 2 deletions backend/hct_mis_api/apps/utils/mailjet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __init__(
self.recipients = settings.CATCH_ALL_EMAIL if settings.CATCH_ALL_EMAIL else recipients
self.ccs = ccs or []
self.variables = variables
self.from_email = from_email or settings.EMAIL_HOST_USER
self.from_email_display = from_email_display or settings.DEFAULT_FROM_EMAIL
self.from_email = from_email or settings.DEFAULT_EMAIL
self.from_email_display = from_email_display or settings.DEFAULT_EMAIL_DISPLAY
self.attachments = []

def _validate_email_data(self) -> None:
Expand Down
2 changes: 2 additions & 0 deletions backend/hct_mis_api/config/fragments/mailjet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
MAILJET_API_KEY = env("MAILJET_API_KEY")
MAILJET_SECRET_KEY = env("MAILJET_SECRET_KEY")
CATCH_ALL_EMAIL = env.list("CATCH_ALL_EMAIL", default=[])
DEFAULT_EMAIL_DISPLAY = env("DEFAULT_EMAIL_DISPLAY", default="")
DEFAULT_EMAIL = env("DEFAULT_EMAIL", default="")
1 change: 1 addition & 0 deletions backend/hct_mis_api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def pytest_configure(config: Config) -> None:
settings.ELASTICSEARCH_INDEX_PREFIX = "test_"
settings.EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
settings.CATCH_ALL_EMAIL = []
settings.DEFAULT_EMAIL = "[email protected]"

settings.EXCHANGE_RATE_CACHE_EXPIRY = 0
settings.USE_DUMMY_EXCHANGE_RATES = True
Expand Down
10 changes: 5 additions & 5 deletions backend/tests/apps/utils/test_mailjet.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_mailjet_body_with_template(self, mocked_requests_post: Any) -> None:
{
"Messages": [
{
"From": {"Email": settings.EMAIL_HOST_USER, "Name": settings.DEFAULT_FROM_EMAIL},
"From": {"Email": settings.DEFAULT_EMAIL, "Name": settings.DEFAULT_EMAIL_DISPLAY},
"Subject": "[test] Subject for email with Template",
"To": [
{
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_mailjet_body_with_template_with_catch_all(self, mocked_requests_post: A
{
"Messages": [
{
"From": {"Email": settings.EMAIL_HOST_USER, "Name": settings.DEFAULT_FROM_EMAIL},
"From": {"Email": settings.DEFAULT_EMAIL, "Name": settings.DEFAULT_EMAIL_DISPLAY},
"Subject": "[test] Subject for email with Template for Catch All",
"To": [
{
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_mailjet_body_with_html_and_text_body(self, mocked_requests_post: Any) -
{
"Messages": [
{
"From": {"Email": settings.EMAIL_HOST_USER, "Name": settings.DEFAULT_FROM_EMAIL},
"From": {"Email": settings.DEFAULT_EMAIL, "Name": settings.DEFAULT_EMAIL_DISPLAY},
"Subject": "[test] Subject for email with HTML and Text body",
"To": [
{
Expand Down Expand Up @@ -171,7 +171,7 @@ def test_mailjet_body_with_text_body(self, mocked_requests_post: Any) -> None:
{
"Messages": [
{
"From": {"Email": settings.EMAIL_HOST_USER, "Name": settings.DEFAULT_FROM_EMAIL},
"From": {"Email": settings.DEFAULT_EMAIL, "Name": settings.DEFAULT_EMAIL_DISPLAY},
"Subject": "[test] Subject for email with Text body",
"To": [
{
Expand Down Expand Up @@ -238,7 +238,7 @@ def test_mailjet_body_with_template_and_attachment(self, mocked_requests_post: A
{
"Messages": [
{
"From": {"Email": settings.EMAIL_HOST_USER, "Name": settings.DEFAULT_FROM_EMAIL},
"From": {"Email": settings.DEFAULT_EMAIL, "Name": settings.DEFAULT_EMAIL_DISPLAY},
"Subject": "[test] Subject for email with Template and Attachments",
"To": [
{
Expand Down

0 comments on commit 1efc38d

Please sign in to comment.