Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2825] Venray/Rx.mission - adding openzaak config option to use zaak.omschrijving if available instead of zaaktype.omschrijving #1453

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/open_inwoner/openzaak/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class OpenZaakConfigAdmin(SingletonModelAdmin):
"fields": (
"enable_categories_filtering_with_zaken",
"zaken_filter_enabled",
"use_zaak_omschrijving_as_title",
),
},
),
Expand Down
15 changes: 13 additions & 2 deletions src/open_inwoner/openzaak/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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)",
),
),
]
13 changes: 13 additions & 0 deletions src/open_inwoner/openzaak/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=_(
Expand Down
36 changes: 35 additions & 1 deletion src/open_inwoner/openzaak/tests/test_api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Loading