diff --git a/src/open_inwoner/conf/parts/maileditor.py b/src/open_inwoner/conf/parts/maileditor.py
index 1644a8343d..926efb3e37 100644
--- a/src/open_inwoner/conf/parts/maileditor.py
+++ b/src/open_inwoner/conf/parts/maileditor.py
@@ -290,16 +290,76 @@
},
],
},
- "case_notification": {
- "name": _("Case update notification"),
+ "case_status_notification": {
+ "name": _("Case status update notification"),
"description": _(
- "This email is used to notify people an update happened to their case"
+ "This email is used to notify people about a new status being set on their case"
),
"subject_default": "Update to your case at {{ site_name }}",
"body_default": """
Beste
- You are receiving this email because one of your cases received a new status update or document attachment.
+ You are receiving this email because one of your cases received a new status update.
+
+
+
+ Case identification |
+ {{ identification }} |
+
+
+ Case type |
+ {{ type_description }} |
+
+
+ Start date |
+ {{ start_date }} |
+
+
+
+ Go to your case
+
+ Met vriendelijke groet,
+ {{ site_name }}
+ """,
+ "subject": [
+ {
+ "name": "site_name",
+ "description": _("Name of the site."),
+ },
+ ],
+ "body": [
+ {
+ "name": "identification",
+ "description": _("The identification of the case"),
+ },
+ {
+ "name": "type_description",
+ "description": _("The description of the type of the case"),
+ },
+ {
+ "name": "start_date",
+ "description": _("The start date of the case"),
+ },
+ {
+ "name": "case_link",
+ "description": _("The link to the case details."),
+ },
+ {
+ "name": "site_name",
+ "description": _("Name of the site"),
+ },
+ ],
+ },
+ "case_document_notification": {
+ "name": _("Case document update notification"),
+ "description": _(
+ "This email is used to notify people that a new document was added to their case"
+ ),
+ "subject_default": "Update to your case at {{ site_name }}",
+ "body_default": """
+ Beste
+
+ You are receiving this email because one of your cases received a new document attachment.
diff --git a/src/open_inwoner/openzaak/migrations/0042_case_notification_mail_template_split.py b/src/open_inwoner/openzaak/migrations/0042_case_notification_mail_template_split.py
new file mode 100644
index 0000000000..bb444a65d3
--- /dev/null
+++ b/src/open_inwoner/openzaak/migrations/0042_case_notification_mail_template_split.py
@@ -0,0 +1,49 @@
+# Generated by Django 3.2.23 on 2024-01-19 15:02
+
+from django.db import migrations
+
+
+def split_case_notification_mail_template(apps, schema_editor):
+ """
+ Split the `case_notification` email template into two separate templates, one for
+ status notifications and one for document notifications
+ """
+ MailTemplate = apps.get_model("mail_editor", "MailTemplate")
+
+ case_notification_template = MailTemplate.objects.filter(
+ template_type="case_notification"
+ ).first()
+
+ if case_notification_template:
+ case_notification_template.template_type = "case_status_notification"
+ case_notification_template.save()
+
+ case_notification_template.pk = None
+ case_notification_template.template_type = "case_document_notification"
+ case_notification_template.save()
+
+
+def join_case_notification_mail_template(apps, schema_editor):
+ MailTemplate = apps.get_model("mail_editor", "MailTemplate")
+
+ case_notification_template = MailTemplate.objects.get(
+ template_type="case_status_notification"
+ )
+ MailTemplate.objects.get(template_type="case_document_notification").delete()
+
+ case_notification_template.template_type = "case_notification"
+ case_notification_template.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("mail_editor", "0001_initial"),
+ ("openzaak", "0041_configuration_cases_button"),
+ ]
+
+ operations = [
+ migrations.RunPython(
+ split_case_notification_mail_template, join_case_notification_mail_template
+ )
+ ]
diff --git a/src/open_inwoner/openzaak/notifications.py b/src/open_inwoner/openzaak/notifications.py
index ae2e85345c..f801ae26ec 100644
--- a/src/open_inwoner/openzaak/notifications.py
+++ b/src/open_inwoner/openzaak/notifications.py
@@ -247,7 +247,7 @@ def handle_zaakinformatieobject_update(
)
return
- send_case_update_email(user, case)
+ send_case_update_email(user, case, "case_document_notification")
note.mark_sent()
log_system_action(
@@ -387,7 +387,7 @@ def handle_status_update(user: User, case: Zaak, status: Status):
)
return
- send_case_update_email(user, case)
+ send_case_update_email(user, case, "case_status_notification")
note.mark_sent()
log_system_action(
@@ -396,7 +396,9 @@ def handle_status_update(user: User, case: Zaak, status: Status):
)
-def send_case_update_email(user: User, case: Zaak):
+def send_case_update_email(
+ user: User, case: Zaak, template_name: str, extra_context: dict = None
+):
"""
send the actual mail
"""
@@ -404,13 +406,15 @@ def send_case_update_email(user: User, case: Zaak):
reverse("cases:case_detail", kwargs={"object_id": str(case.uuid)})
)
- template = find_template("case_notification")
+ template = find_template(template_name)
context = {
"identification": case.identification,
"type_description": case.zaaktype.omschrijving,
"start_date": case.startdatum,
"case_link": case_detail_url,
}
+ if extra_context:
+ context.update(extra_context)
template.send_email([user.email], context)
diff --git a/src/open_inwoner/openzaak/tests/test_notification_utils.py b/src/open_inwoner/openzaak/tests/test_notification_utils.py
index 66ef357a28..55736d4caa 100644
--- a/src/open_inwoner/openzaak/tests/test_notification_utils.py
+++ b/src/open_inwoner/openzaak/tests/test_notification_utils.py
@@ -42,7 +42,7 @@ def test_send_case_update_email(self):
Zaak, "_format_zaak_identificatie"
) as format_identificatie:
format_identificatie.return_value = ret_val
- send_case_update_email(user, case)
+ send_case_update_email(user, case, "case_status_notification")
format_identificatie.assert_called_once()