Skip to content

Commit ecb2b35

Browse files
committed
✨(email) white brand email
The email was branded "La Suite Numérique", we updated the template to make it generic, we will use settings env variables to customize the email for each brand.
1 parent 2d13e09 commit ecb2b35

File tree

14 files changed

+416
-308
lines changed

14 files changed

+416
-308
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to
1212
## Added
1313

1414
- ✨(backend) add server-to-server API endpoint to create documents #467
15+
- ✨(email) white brand email #412
1516

1617

1718
## [1.9.0] - 2024-12-11

env.d/development/common.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ PYTHONPATH=/app
1616
# impress settings
1717

1818
# Mail
19+
DJANGO_EMAIL_BRAND_NAME="La Suite Numérique"
1920
DJANGO_EMAIL_HOST="mailcatcher"
21+
DJANGO_EMAIL_LOGO_IMG="http://localhost:3000/assets/logo-suite-numerique.png"
2022
DJANGO_EMAIL_PORT=1025
2123

2224
# Backend url

src/backend/core/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,11 @@ def send_email(self, subject, emails, context=None, language=None):
552552
language = language or get_language()
553553
context.update(
554554
{
555+
"brandname": settings.EMAIL_BRAND_NAME,
556+
"document": self,
555557
"domain": domain,
556558
"link": f"{domain}/docs/{self.id}/",
557-
"document": self,
559+
"logo_img": settings.EMAIL_LOGO_IMG,
558560
}
559561
)
560562

src/backend/core/tests/documents/test_api_document_invitations.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from unittest import mock
88

99
from django.core import mail
10+
from django.test import override_settings
1011
from django.utils import timezone
1112

1213
import pytest
@@ -339,6 +340,7 @@ def test_api_document_invitations_create_authenticated_outsider():
339340
assert response.status_code == 403
340341

341342

343+
@override_settings(EMAIL_BRAND_NAME="My brand name", EMAIL_LOGO_IMG="my-img.jpg")
342344
@pytest.mark.parametrize(
343345
"inviting,invited,response_code",
344346
(
@@ -407,6 +409,8 @@ def test_api_document_invitations_create_privileged_members(
407409
f"{user.full_name} ({user.email}) invited you with the role ``{invited}`` "
408410
f"on the following document: {document.title}"
409411
) in email_content
412+
assert "My brand name" in email_content
413+
assert "my-img.jpg" in email_content
410414
else:
411415
assert models.Invitation.objects.exists() is False
412416

@@ -453,7 +457,7 @@ def test_api_document_invitations_create_email_from_content_language():
453457
assert email.to == ["[email protected]"]
454458

455459
email_content = " ".join(email.body.split())
456-
assert f"{user.full_name} a partagé un document avec vous !" in email_content
460+
assert f"{user.full_name} a partagé un document avec vous!" in email_content
457461

458462

459463
def test_api_document_invitations_create_email_from_content_language_not_supported():

src/backend/impress/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,11 @@ class Base(Configuration):
352352

353353
# Mail
354354
EMAIL_BACKEND = values.Value("django.core.mail.backends.smtp.EmailBackend")
355+
EMAIL_BRAND_NAME = values.Value(None)
355356
EMAIL_HOST = values.Value(None)
356357
EMAIL_HOST_USER = values.Value(None)
357358
EMAIL_HOST_PASSWORD = values.Value(None)
359+
EMAIL_LOGO_IMG = values.Value(None)
358360
EMAIL_PORT = values.PositiveIntegerValue(None)
359361
EMAIL_USE_TLS = values.BooleanValue(False)
360362
EMAIL_USE_SSL = values.BooleanValue(False)
51 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)