Skip to content

Commit e46480d

Browse files
swrichardspi-sigma
authored andcommitted
fix: [#2803] make OpenZaakConfig.document_visible_statuses emptyable
Backport-Of: #2805
1 parent f613b33 commit e46480d

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Generated by Django 5.2.17 on 2026-08-13 11:53
2+
3+
from django.db import migrations, models
4+
5+
import django_jsonform.models.fields
6+
7+
import open_inwoner.openzaak.models
8+
9+
10+
class Migration(migrations.Migration):
11+
dependencies = [
12+
("openzaak", "0085_zaaktypeconfig_zaken_visible_from"),
13+
]
14+
15+
operations = [
16+
migrations.AlterField(
17+
model_name="openzaakconfig",
18+
name="document_visible_statuses",
19+
field=django_jsonform.models.fields.ArrayField(
20+
base_field=models.CharField(
21+
choices=[
22+
("in_bewerking", "In bewerking"),
23+
("ter_vaststelling", "Ter vaststelling"),
24+
("definitief", "Definitief"),
25+
("gearchiveerd", "Gearchiveerd"),
26+
],
27+
max_length=32,
28+
),
29+
blank=True,
30+
default=open_inwoner.openzaak.models.default_document_visible_statuses,
31+
help_text="Select which document statuses are visible to users. Documents with other statuses will be hidden. Warning: selecting no statuses means documents with any status will be visible.",
32+
size=None,
33+
verbose_name="Visible document statuses",
34+
),
35+
),
36+
]

src/open_inwoner/openzaak/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ def form_services(self):
425425
choices=InformatieObjectStatus.choices,
426426
),
427427
default=default_document_visible_statuses,
428+
blank=True,
428429
verbose_name=_("Visible document statuses"),
429430
help_text=_(
430431
"Select which document statuses are visible to users. "

src/open_inwoner/openzaak/tests/test_admin.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from open_inwoner.accounts.tests.factories import UserFactory
1919
from open_inwoner.openzaak.api_models import ResultaatType
20+
from open_inwoner.openzaak.models import OpenZaakConfig
2021

2122
from .factories import (
2223
CatalogusConfigFactory,
@@ -408,3 +409,33 @@ def test_import_view_requires_change_permission(self):
408409
)
409410

410411
self.assertEqual(response.status_code, 403)
412+
413+
414+
@disable_admin_mfa()
415+
class TestOpenZaakConfigAdmin(WebTest):
416+
def setUp(self):
417+
self.user = UserFactory(is_superuser=True, is_staff=True)
418+
self.form = self.app.get(
419+
reverse("admin:openzaak_openzaakconfig_change"), user=self.user
420+
).forms["openzaakconfig_form"]
421+
# django-jsonform requires JS to work properly and with Webtest the default
422+
# value for ArrayFields is an empty string, causing it to crash when trying to
423+
# parse that value as JSON
424+
self.form["allowed_file_extensions"] = json.dumps(
425+
OpenZaakConfig.get_solo().allowed_file_extensions
426+
)
427+
428+
def test_document_visible_statuses_can_be_saved_as_empty_list(self):
429+
"""An empty `document_visible_statuses` is valid and means all statuses
430+
are visible (see `test_utils.test_is_info_object_visible_custom_statuses`),
431+
so the admin form must allow saving it as such."""
432+
config = OpenZaakConfig.get_solo()
433+
self.assertNotEqual(config.document_visible_statuses, [])
434+
435+
self.form["document_visible_statuses"] = "[]"
436+
response = self.form.submit()
437+
438+
self.assertEqual(response.status_code, 302)
439+
440+
config.refresh_from_db()
441+
self.assertEqual(config.document_visible_statuses, [])

0 commit comments

Comments
 (0)