Skip to content

Commit

Permalink
Merge pull request #892 from maykinmedia/issue/1932-keyerror-zaaktype…
Browse files Browse the repository at this point in the history
…-identificatie

[#1932] Skipping zaaktype in case identificatie doesn't exist in zaaktype list
  • Loading branch information
stevenbal authored Dec 14, 2023
2 parents 295c967 + 1ce761d commit 72bd3a2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/open_inwoner/cms/products/tests/test_plugin_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def setUpTestData(cls):
cls.category2 = CategoryFactory(
name="0002",
highlighted=True,
zaaktypen=["ZAAKTYPE-2020-0000000001"],
zaaktypen=["ZAAKTYPE-2020-0000000001", "ZAAKTYPE-2020-0000000003"],
visible_for_citizens=True,
)
cls.category3 = CategoryFactory(
Expand Down Expand Up @@ -365,6 +365,31 @@ def setUpTestData(cls):
beginGeldigheid="2020-09-25",
versiedatum="2020-09-25",
)
# For https://taiga.maykinmedia.nl/project/open-inwoner/issue/1932
# This zaaktype is linked to a Category, but the user does not have a Zaak with
# this Zaaktype and filtering should not fail because of this
cls.zaaktype3 = generate_oas_component(
"ztc",
"schemas/ZaakType",
uuid="bd0fab67-c7b8-429d-973d-7bece55be710",
url="http://testserver/zaaktype/bd0fab67-c7b8-429d-973d-7bece55be710",
identificatie="ZAAKTYPE-2020-0000000003",
omschrijving="foo zaaktype",
catalogus=f"{CATALOGI_ROOT}catalogussen/1b643db-81bb-d71bd5a2317a",
vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduidingen.openbaar,
doel="Ask for coffee",
aanleiding="Coffee is essential",
indicatieInternOfExtern="extern",
handelingInitiator="Request",
onderwerp="Coffee",
handelingBehandelaar="Behandelen",
opschortingEnAanhoudingMogelijk=False,
verlengingMogelijk=False,
publicatieIndicatie=False,
besluittypen=[],
beginGeldigheid="2020-09-25",
versiedatum="2020-09-25",
)
cls.zaaktype_config1 = ZaakTypeConfigFactory(
catalogus__url=f"{CATALOGI_ROOT}catalogussen/1b643db-81bb-d71bd5a2317a",
urls=[cls.zaaktype["url"]],
Expand All @@ -377,6 +402,12 @@ def setUpTestData(cls):
identificatie=cls.zaaktype2["identificatie"],
relevante_zaakperiode=1,
)
cls.zaaktype_config3 = ZaakTypeConfigFactory(
catalogus=cls.zaaktype_config1.catalogus,
urls=[cls.zaaktype3["url"]],
identificatie=cls.zaaktype3["identificatie"],
relevante_zaakperiode=2,
)

def _setUpOASMocks(self, m):
mock_service_oas_get(m, ZAKEN_ROOT, "zrc")
Expand All @@ -392,6 +423,7 @@ def _setUpMocks(self, m):
self.zaak3,
self.zaaktype,
self.zaaktype2,
self.zaaktype3,
]:
m.get(resource["url"], json=resource)

Expand Down
2 changes: 2 additions & 0 deletions src/open_inwoner/pdc/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def filter_for_user_with_zaken(self, user: User):
pks = []
for category in qs:
for identificatie in category.zaaktypen:
if not identificatie in months_since_last_zaak_per_zaaktype:
continue
relevante_zaakperiode = zaakperiode_mapping.get(identificatie)
if not relevante_zaakperiode:
pks.append(category.pk)
Expand Down

0 comments on commit 72bd3a2

Please sign in to comment.