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

[Venray #121] Support sorting the statusses on date set (Rx.mission, Open Zaak) #1446

Merged
merged 1 commit into from
Oct 22, 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
7 changes: 5 additions & 2 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_statuses_by_date_set:
statuses.sort(key=lambda s: s.datum_status_gezet)
else:
statuses.reverse()

# get preview of second status
if len(statuses) == 1:
Expand Down
1 change: 1 addition & 0 deletions src/open_inwoner/openzaak/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class OpenZaakConfigAdmin(SingletonModelAdmin):
"enable_categories_filtering_with_zaken",
"zaken_filter_enabled",
"use_zaak_omschrijving_as_title",
"order_statuses_by_date_set",
),
},
),
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-15 10:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("openzaak", "0056_openzaakconfig_use_zaak_omschrijving_as_title"),
]

operations = [
migrations.AddField(
model_name="openzaakconfig",
name="order_statuses_by_date_set",
field=models.BooleanField(
default=False,
help_text="If enabled, the statuses of a case are ordered based on 'datum_status_gezet'. If not enabled, we show the statuses in the reverse order they are returned via the API, this because the eSuite does not return the timestamps of the statuses (eSuite, but also works for Open Zaak).",
verbose_name="On the detail page of the case, order the statuses based on the date they have been set",
),
),
]
13 changes: 13 additions & 0 deletions src/open_inwoner/openzaak/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,19 @@ def form_service(self, service):
default=False,
)

order_statuses_by_date_set = models.BooleanField(
verbose_name=_(
"On the detail page of the case, order the statuses based on the date they have been set"
),
help_text=_(
"If enabled, the statuses of a case are ordered based on 'datum_status_gezet'. "
"If not enabled, we show the statuses in the reverse order they are returned via the API, "
"this because the eSuite does not return the timestamps of the statuses (eSuite, but also "
"works for Open Zaak)."
),
default=False,
)

title_text = models.TextField(
verbose_name=_("Title text"),
help_text=_(
Expand Down
45 changes: 45 additions & 0 deletions src/open_inwoner/openzaak/tests/test_case_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2485,3 +2485,48 @@ def test_objectcontactmoment_with_contactmoment_null(self, m, cm_client_mock):
response = self.app.get(self.case_detail_url, user=self.eherkenning_user)

self.assertEqual(response.status_code, 200)

def test_zaak_status_ordering(self, m):
self._setUpMocks(m)

status_type_intermediate = generate_oas_component_cached(
"ztc",
"schemas/StatusType",
url=f"{CATALOGI_ROOT}statustypen/625f373c-2828-49b3-9a29-bc36dc84d729",
zaaktype=self.zaaktype["url"],
catalogus=f"{CATALOGI_ROOT}catalogussen/1b643db-81bb-d71bd5a2317a",
omschrijving="Intermediate request",
omschrijvingGeneriek="some content",
statustekst="Modified",
volgnummer=2,
isEindstatus=False,
)
status_intermediate = generate_oas_component_cached(
"zrc",
"schemas/Status",
url=f"{ZAKEN_ROOT}statussen/07a4ae16-8eea-4a93-a01a-f822d7235d0c",
zaak=self.zaak["url"],
statustype=status_type_intermediate["url"],
datumStatusGezet="2021-02-12",
statustoelichting="",
)

for resource in [status_type_intermediate, status_intermediate]:
m.get(resource["url"], json=resource)

m.get(
f"{ZAKEN_ROOT}statussen?zaak={self.zaak['url']}",
json=paginated_response(
[status_intermediate, self.status_new, self.status_finish]
),
)

self.config.order_statuses_by_date_set = True
self.config.save()

response = self.app.get(self.case_detail_url, user=self.user)
case = response.context.get("case")

self.assertEqual(case["statuses"][0]["label"], "Registered")
self.assertEqual(case["statuses"][1]["label"], "Modified")
self.assertEqual(case["statuses"][2]["label"], "Finish")
Loading