Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2477] Add site name to dynamic mail context #1221

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/open_inwoner/mail/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def mail_context():
"""
context = {}
config = SiteConfiguration.get_solo()
context["site_name"] = config.name or "Open Inwoner Platform"
context["logo"] = config.email_logo
context["theming"] = {
"primary_color": config.primary_color,
Expand Down
2 changes: 2 additions & 0 deletions src/open_inwoner/mail/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ def test_context_ok(self):

self.assertIn("contact_page", context)
self.assertIn("contact_phonenumber", context)

self.assertIn("site_name", context)
8 changes: 7 additions & 1 deletion src/open_inwoner/mail/tests/test_service.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
from django.core import mail
from django.test import TestCase

from open_inwoner.configurations.models import SiteConfiguration
from open_inwoner.mail.service import send_contact_confirmation_mail


class TestServices(TestCase):
def test_send_contact_confirmation_mail(self):
# for checking that site_name is properly displayed
config = SiteConfiguration.get_solo()
config.name = "Spam Producent"
config.save()

send_contact_confirmation_mail("foo@example.com", "My subject")

self.assertEqual(len(mail.outbox), 1)

sent_mail = mail.outbox[0]
html_body = sent_mail.alternatives[0][0]

self.assertIn("Vraag ontvangen op ", sent_mail.subject)
self.assertIn("Vraag ontvangen op Spam Producent", sent_mail.subject)
self.assertEqual(sent_mail.to, ["foo@example.com"])
self.assertIn("My subject", html_body)
Loading