diff --git a/src/open_inwoner/openzaak/admin.py b/src/open_inwoner/openzaak/admin.py index 97165f3d72..9c9f70f6f8 100644 --- a/src/open_inwoner/openzaak/admin.py +++ b/src/open_inwoner/openzaak/admin.py @@ -69,6 +69,7 @@ class OpenZaakConfigAdmin(SingletonModelAdmin): "fields": ( "enable_categories_filtering_with_zaken", "zaken_filter_enabled", + "use_zaak_omschrijving_as_title", ), }, ), diff --git a/src/open_inwoner/openzaak/api_models.py b/src/open_inwoner/openzaak/api_models.py index d2d440d036..13f29aa169 100644 --- a/src/open_inwoner/openzaak/api_models.py +++ b/src/open_inwoner/openzaak/api_models.py @@ -91,17 +91,28 @@ def status_text(self) -> str: return _status_text + @property + def description(self) -> str: + from open_inwoner.openzaak.models import OpenZaakConfig + + zaak_config = OpenZaakConfig.get_solo() + + description = self.zaaktype.omschrijving + if zaak_config.use_zaak_omschrijving_as_title and self.omschrijving: + description = self.omschrijving + + return description + def process_data(self) -> dict: """ Prepare data for template """ - return { "identification": self.identification, "uuid": str(self.uuid), "start_date": self.startdatum, "end_date": getattr(self, "einddatum", None), - "description": self.zaaktype.omschrijving, + "description": self.description, "current_status": self.status_text, "zaaktype_config": getattr(self, "zaaktype_config", None), "statustype_config": getattr(self, "statustype_config", None), diff --git a/src/open_inwoner/openzaak/migrations/0056_openzaakconfig_use_zaak_omschrijving_as_title.py b/src/open_inwoner/openzaak/migrations/0056_openzaakconfig_use_zaak_omschrijving_as_title.py new file mode 100644 index 0000000000..90f86eaa68 --- /dev/null +++ b/src/open_inwoner/openzaak/migrations/0056_openzaakconfig_use_zaak_omschrijving_as_title.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.16 on 2024-10-21 13:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("openzaak", "0055_openzaakconfig_zaken_filter_enabled"), + ] + + operations = [ + migrations.AddField( + model_name="openzaakconfig", + name="use_zaak_omschrijving_as_title", + field=models.BooleanField( + default=False, + help_text="If enabled, we use zaak.omschrijving for the title of the cases, and use zaaktype.omschrijving as a fallback in case it is not filled in. If not enabled, we ignore zaak.omschrijving and always use zaaktype.omschrijving.", + verbose_name="Make use of zaak.omschrijving for the title of the cases instead of zaaktype.omschrijving (eSuite)", + ), + ), + ] diff --git a/src/open_inwoner/openzaak/models.py b/src/open_inwoner/openzaak/models.py index 07edbaf54e..dedd52e480 100644 --- a/src/open_inwoner/openzaak/models.py +++ b/src/open_inwoner/openzaak/models.py @@ -412,6 +412,19 @@ def form_service(self, service): default=False, ) + use_zaak_omschrijving_as_title = models.BooleanField( + verbose_name=_( + "Make use of zaak.omschrijving for the title of the cases instead of " + "zaaktype.omschrijving (eSuite)" + ), + help_text=_( + "If enabled, we use zaak.omschrijving for the title of the cases, and use " + "zaaktype.omschrijving as a fallback in case it is not filled in. " + "If not enabled, we ignore zaak.omschrijving and always use zaaktype.omschrijving." + ), + default=False, + ) + title_text = models.TextField( verbose_name=_("Title text"), help_text=_( diff --git a/src/open_inwoner/openzaak/tests/test_api_models.py b/src/open_inwoner/openzaak/tests/test_api_models.py index 22e41e4072..a96def2467 100644 --- a/src/open_inwoner/openzaak/tests/test_api_models.py +++ b/src/open_inwoner/openzaak/tests/test_api_models.py @@ -3,7 +3,8 @@ from zgw_consumers.api_models.base import factory -from open_inwoner.openzaak.api_models import Zaak +from open_inwoner.openzaak.api_models import Zaak, ZaakType +from open_inwoner.openzaak.models import OpenZaakConfig class ZaakAPIModelTest(TestCase): @@ -90,3 +91,36 @@ def test_status_text_default(self): case = factory(Zaak, data=self.zaak_data) self.assertEqual(case.status_text, _("No data available")) + + def test_zaak_omschrijving(self): + zaaktype = factory( + ZaakType, + data={ + "url": "https://example.com", + "identificatie": "VTH001", + "catalogus": "https://example.com", + "vertrouwelijkheidaanduiding": "openbaar", + "doel": "-", + "aanleiding": "-", + "indicatie_intern_of_extern": "extern", + "handeling_initiator": "Aanvragen", + "onderwerp": "VTH", + "handeling_behandelaar": "Behandelen", + "statustypen": [], + "resultaattypen": [], + "informatieobjecttypen": [], + "omschrijving": "Vergunning", + }, + ) + self.zaak_data["zaaktype"] = zaaktype + self.zaak_data["omschrijving"] = "Vergunning voor Joeri" + + case = factory(Zaak, data=self.zaak_data) + + self.assertEqual(case.description, "Vergunning") + + zaak_config = OpenZaakConfig.get_solo() + zaak_config.use_zaak_omschrijving_as_title = True + zaak_config.save() + + self.assertEqual(case.description, "Vergunning voor Joeri")