diff --git a/src/open_inwoner/cms/cases/views/services.py b/src/open_inwoner/cms/cases/views/services.py index d9ae67e08c..88fb303a4e 100644 --- a/src/open_inwoner/cms/cases/views/services.py +++ b/src/open_inwoner/cms/cases/views/services.py @@ -196,9 +196,7 @@ def _get_cases_for_api_group(self, group: ZGWApiGroupConfig) -> list[Zaak]: ) resolved_cases = self.resolve_cases(raw_cases, group) - filtered_cases = [ - case for case in resolved_cases if case.status and is_zaak_visible(case) - ] + filtered_cases = [case for case in resolved_cases if is_zaak_visible(case)] filtered_cases.sort(key=lambda case: case.startdatum, reverse=True) return filtered_cases diff --git a/src/open_inwoner/openzaak/migrations/0059_openzaakconfig_show_cases_without_status.py b/src/open_inwoner/openzaak/migrations/0059_openzaakconfig_show_cases_without_status.py new file mode 100644 index 0000000000..bdea234edf --- /dev/null +++ b/src/open_inwoner/openzaak/migrations/0059_openzaakconfig_show_cases_without_status.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.16 on 2024-12-11 19:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ( + "openzaak", + "0058_remove_zaaktypeconfig_unique_identificatie_in_catalogus_and_more", + ), + ] + + operations = [ + migrations.AddField( + model_name="openzaakconfig", + name="show_cases_without_status", + field=models.BooleanField( + default=False, + verbose_name="By default cases are only shown if they have a status set.", + ), + ), + ] diff --git a/src/open_inwoner/openzaak/models.py b/src/open_inwoner/openzaak/models.py index 85eaf4f157..e570e86e6e 100644 --- a/src/open_inwoner/openzaak/models.py +++ b/src/open_inwoner/openzaak/models.py @@ -438,6 +438,11 @@ def form_service(self, service): default=False, ) + show_cases_without_status = models.BooleanField( + verbose_name=_("By default cases are only shown if they have a status set."), + default=False, + ) + title_text = models.TextField( verbose_name=_("Title text"), help_text=_( diff --git a/src/open_inwoner/openzaak/tests/test_utils.py b/src/open_inwoner/openzaak/tests/test_utils.py index d04ea8968b..4be9ba83b4 100644 --- a/src/open_inwoner/openzaak/tests/test_utils.py +++ b/src/open_inwoner/openzaak/tests/test_utils.py @@ -142,6 +142,12 @@ def test_is_zaak_visible(self): # resolve the zaaktype zaak.zaaktype = zaaktype + with self.subTest("normal visible without status"): + self.assertFalse(is_zaak_visible(zaak)) + + config.show_cases_without_status = True + config.save() + with self.subTest("normal visible"): self.assertTrue(is_zaak_visible(zaak)) diff --git a/src/open_inwoner/openzaak/utils.py b/src/open_inwoner/openzaak/utils.py index b9786229f0..b29ba6f8e1 100644 --- a/src/open_inwoner/openzaak/utils.py +++ b/src/open_inwoner/openzaak/utils.py @@ -49,6 +49,9 @@ def is_zaak_visible(zaak: Zaak) -> bool: if isinstance(zaak.zaaktype, str): raise ValueError("expected zaak.zaaktype to be resolved from url to model") + if not zaak.status and not config.show_cases_without_status: + return False + if not zaak.zaaktype or zaak.zaaktype.indicatie_intern_of_extern != "extern": return False