From 2000117e89a5062d76adcde6b6934cfa86a5feb1 Mon Sep 17 00:00:00 2001 From: Alex de Landgraaf Date: Tue, 15 Oct 2024 12:12:42 +0200 Subject: [PATCH 1/5] [Venray #121] Support sorting the statusses on date set (Rx.mission, Open Zaak) --- src/open_inwoner/cms/cases/views/status.py | 7 ++++-- ...nzaakconfig_order_statusses_by_date_set.py | 22 +++++++++++++++++++ src/open_inwoner/openzaak/models.py | 11 ++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/open_inwoner/openzaak/migrations/0056_openzaakconfig_order_statusses_by_date_set.py diff --git a/src/open_inwoner/cms/cases/views/status.py b/src/open_inwoner/cms/cases/views/status.py index 90cd53ed76..62f03cdf10 100644 --- a/src/open_inwoner/cms/cases/views/status.py +++ b/src/open_inwoner/cms/cases/views/status.py @@ -189,11 +189,14 @@ def get_context_data(self, **kwargs): self.case.zaaktype.url ) - # NOTE we cannot sort on the Status.datum_status_gezet (datetime) because eSuite + # NOTE we cannot always sort on the Status.datum_status_gezet (datetime) because eSuite # returns zeros as the time component of the datetime, so we're going with the # observation that on both OpenZaak and eSuite the returned list is ordered 'oldest-last' # here we want it 'oldest-first' so we reverse() it instead of sort()-ing - statuses.reverse() + if config.order_statusses_by_date_set: + statuses.sort() + else: + statuses.reverse() # get preview of second status if len(statuses) == 1: diff --git a/src/open_inwoner/openzaak/migrations/0056_openzaakconfig_order_statusses_by_date_set.py b/src/open_inwoner/openzaak/migrations/0056_openzaakconfig_order_statusses_by_date_set.py new file mode 100644 index 0000000000..80a44d1054 --- /dev/null +++ b/src/open_inwoner/openzaak/migrations/0056_openzaakconfig_order_statusses_by_date_set.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.16 on 2024-10-15 10:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("openzaak", "0055_openzaakconfig_zaken_filter_enabled"), + ] + + operations = [ + migrations.AddField( + model_name="openzaakconfig", + name="order_statusses_by_date_set", + field=models.BooleanField( + default=False, + help_text="If enabled, order the statusses of a case based on 'datum_status_gezet'. If not enabled, we show the statusses in the reverse order they are returned via the API, this because the eSuite does not return the timestamps of the statusses (eSuite, but also works for Open Zaak).", + verbose_name="On the detail page of the case, order the statusses on the date they have been set", + ), + ), + ] diff --git a/src/open_inwoner/openzaak/models.py b/src/open_inwoner/openzaak/models.py index 07edbaf54e..672d30241a 100644 --- a/src/open_inwoner/openzaak/models.py +++ b/src/open_inwoner/openzaak/models.py @@ -412,6 +412,17 @@ def form_service(self, service): default=False, ) + order_statusses_by_date_set = models.BooleanField( + verbose_name=_( + "On the detail page of the case, order the statusses on the date they have been set" + ), + help_text=_( + "If enabled, order the statusses of a case based on 'datum_status_gezet'. " + "If not enabled, we show the statusses in the reverse order they are returned via the API, this because the eSuite does not return the timestamps of the statusses (eSuite, but also works for Open Zaak)." + ), + default=False, + ) + title_text = models.TextField( verbose_name=_("Title text"), help_text=_( From 13f0442e751fa9a3b0ebd28c7d3a3830b01638b6 Mon Sep 17 00:00:00 2001 From: Alex de Landgraaf Date: Wed, 16 Oct 2024 14:55:45 +0200 Subject: [PATCH 2/5] Update status.py --- src/open_inwoner/cms/cases/views/status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/open_inwoner/cms/cases/views/status.py b/src/open_inwoner/cms/cases/views/status.py index 62f03cdf10..1c6150d148 100644 --- a/src/open_inwoner/cms/cases/views/status.py +++ b/src/open_inwoner/cms/cases/views/status.py @@ -194,7 +194,7 @@ def get_context_data(self, **kwargs): # observation that on both OpenZaak and eSuite the returned list is ordered 'oldest-last' # here we want it 'oldest-first' so we reverse() it instead of sort()-ing if config.order_statusses_by_date_set: - statuses.sort() + statuses.sort(key=lambda s: s.datum_status_gezet) else: statuses.reverse() From f9c41a11ae51b53806ad0043115c7f7175203507 Mon Sep 17 00:00:00 2001 From: Alex de Landgraaf Date: Mon, 21 Oct 2024 21:50:51 +0200 Subject: [PATCH 3/5] Merging --- src/open_inwoner/openzaak/admin.py | 1 + src/open_inwoner/openzaak/api_models.py | 15 ++++++-- ...akconfig_use_zaak_omschrijving_as_title.py | 22 ++++++++++++ src/open_inwoner/openzaak/models.py | 12 +++++++ .../openzaak/tests/test_api_models.py | 36 ++++++++++++++++++- 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 src/open_inwoner/openzaak/migrations/0056_openzaakconfig_use_zaak_omschrijving_as_title.py 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 672d30241a..ca9f39f385 100644 --- a/src/open_inwoner/openzaak/models.py +++ b/src/open_inwoner/openzaak/models.py @@ -420,6 +420,18 @@ def form_service(self, service): "If enabled, order the statusses of a case based on 'datum_status_gezet'. " "If not enabled, we show the statusses in the reverse order they are returned via the API, this because the eSuite does not return the timestamps of the statusses (eSuite, but also works for Open Zaak)." ), + ) + + 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, ) 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") From e86ed0a805b814ff320c5f147b27713a1bf06d82 Mon Sep 17 00:00:00 2001 From: Alex de Landgraaf Date: Fri, 18 Oct 2024 18:18:56 +0200 Subject: [PATCH 4/5] [#2825] Venray/Rx.mission - use zaak.omschrijving if available instead of zaaktype.omschrijving From 9304560bcf77ffc8257d3185fa26a5e5d012f0d9 Mon Sep 17 00:00:00 2001 From: Alex de Landgraaf Date: Mon, 21 Oct 2024 21:57:20 +0200 Subject: [PATCH 5/5] Merge migration --- .../openzaak/migrations/0057_merge_20241021_2155.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/open_inwoner/openzaak/migrations/0057_merge_20241021_2155.py diff --git a/src/open_inwoner/openzaak/migrations/0057_merge_20241021_2155.py b/src/open_inwoner/openzaak/migrations/0057_merge_20241021_2155.py new file mode 100644 index 0000000000..2ab8f5154a --- /dev/null +++ b/src/open_inwoner/openzaak/migrations/0057_merge_20241021_2155.py @@ -0,0 +1,13 @@ +# Generated by Django 4.2.16 on 2024-10-21 19:55 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("openzaak", "0056_openzaakconfig_order_statusses_by_date_set"), + ("openzaak", "0056_openzaakconfig_use_zaak_omschrijving_as_title"), + ] + + operations = []