Skip to content

Commit

Permalink
Merge pull request #1528 from maykinmedia/issue/venray-133-show-cases…
Browse files Browse the repository at this point in the history
…-no-status

[Venray #133] Adding a featureflag to allow showing cases without a status
  • Loading branch information
alextreme authored Dec 16, 2024
2 parents a4eb8ae + 65b43b2 commit 94fb79b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/open_inwoner/cms/cases/views/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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.",
),
),
]
5 changes: 5 additions & 0 deletions src/open_inwoner/openzaak/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=_(
Expand Down
6 changes: 6 additions & 0 deletions src/open_inwoner/openzaak/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
3 changes: 3 additions & 0 deletions src/open_inwoner/openzaak/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 94fb79b

Please sign in to comment.