Skip to content

Commit 20cd7ce

Browse files
pi-sigmaswrichards
authored andcommitted
[#2823] Filter contactmomenten on Mijn Vragen based on kanaal
1 parent 0ee4d7d commit 20cd7ce

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

src/open_inwoner/cms/cases/views/status.py

+11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from django.views.generic import FormView, TemplateView
2121

2222
from django_htmx.http import HttpResponseClientRedirect
23+
from glom import glom
2324
from mail_editor.helpers import find_template
2425
from view_breadcrumbs import BaseBreadcrumbMixin
2526
from zgw_consumers.api_models.constants import RolOmschrijving
@@ -163,6 +164,7 @@ def get_context_data(self, **kwargs):
163164
self.store_statustype_mapping(self.case.zaaktype.identificatie)
164165
self.store_resulttype_mapping(self.case.zaaktype.identificatie)
165166

167+
# questions/E-suite contactmomenten
166168
objectcontactmomenten = []
167169
if contactmoment_client := build_contactmomenten_client():
168170
objectcontactmomenten = (
@@ -183,6 +185,15 @@ def get_context_data(self, **kwargs):
183185
question, kcm_answer_mapping
184186
)
185187

188+
# filter questions
189+
openklant_config = OpenKlantConfig.get_solo()
190+
if exclude_range := openklant_config.exclude_contactmoment_kanalen:
191+
questions = [
192+
item
193+
for item in questions
194+
if glom(item, "kanaal") not in exclude_range
195+
]
196+
186197
statustypen = []
187198
catalogi_client = api_group.catalogi_client
188199
statustypen = catalogi_client.fetch_status_types_no_cache(

src/open_inwoner/openzaak/tests/test_case_detail.py

+45-3
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,19 @@ def setUp(self):
532532
antwoord="no",
533533
onderwerp="e_suite_subject_code",
534534
)
535+
self.contactmoment_balie = generate_oas_component_cached(
536+
"cmc",
537+
"schemas/Contactmoment",
538+
url=f"{CONTACTMOMENTEN_ROOT}contactmoment/aaaaaaaa-aaaa-aaaa-aaaa-cccccccccccc",
539+
bronorganisatie="123456789",
540+
identificatie="AB123",
541+
registratiedatum="2024-09-27T03:39:28+00:00",
542+
type="SomeType",
543+
kanaal="Balie",
544+
status=ContactMomentStatus.afgehandeld,
545+
antwoord="no",
546+
onderwerp="e_suite_subject_code",
547+
)
535548
self.objectcontactmoment_old = generate_oas_component_cached(
536549
"cmc",
537550
"schemas/Objectcontactmoment",
@@ -548,6 +561,14 @@ def setUp(self):
548561
object_type="zaak",
549562
contactmoment=self.contactmoment_new["url"],
550563
)
564+
self.objectcontactmoment_balie = generate_oas_component_cached(
565+
"cmc",
566+
"schemas/Objectcontactmoment",
567+
url=f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten/bb51784c-fa2c-4f65-b24e-7179b615efac",
568+
object=self.zaak["url"],
569+
object_type="zaak",
570+
contactmoment=self.contactmoment_balie["url"],
571+
)
551572
self.objectcontactmoment_eherkenning = generate_oas_component_cached(
552573
"cmc",
553574
"schemas/Objectcontactmoment",
@@ -625,8 +646,10 @@ def _setUpMocks(self, m, use_eindstatus=True):
625646
self.status_type_finish,
626647
self.contactmoment_old,
627648
self.contactmoment_new,
649+
self.contactmoment_balie,
628650
self.objectcontactmoment_old,
629651
self.objectcontactmoment_new,
652+
self.objectcontactmoment_balie,
630653
]:
631654
m.get(resource["url"], json=resource)
632655

@@ -707,7 +730,11 @@ def _setUpMocks(self, m, use_eindstatus=True):
707730
m.get(
708731
f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten?object={self.zaak['url']}",
709732
json=paginated_response(
710-
[self.objectcontactmoment_old, self.objectcontactmoment_new]
733+
[
734+
self.objectcontactmoment_old,
735+
self.objectcontactmoment_new,
736+
self.objectcontactmoment_balie,
737+
]
711738
),
712739
)
713740

@@ -719,7 +746,11 @@ def _setUpMocks(self, m, use_eindstatus=True):
719746
m.get(
720747
f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten?object={self.zaak['url']}",
721748
json=paginated_response(
722-
[self.objectcontactmoment_old, self.objectcontactmoment_new]
749+
[
750+
self.objectcontactmoment_old,
751+
self.objectcontactmoment_new,
752+
self.objectcontactmoment_balie,
753+
]
723754
),
724755
)
725756

@@ -870,6 +901,9 @@ def test_status_is_retrieved_when_user_logged_in_via_digid(
870901
status_new_obj.statustype = factory(StatusType, self.status_type_new)
871902
status_finish_obj.statustype = factory(StatusType, self.status_type_finish)
872903

904+
self.openklant_config.exclude_contactmoment_kanalen = ["Balie"]
905+
self.openklant_config.save()
906+
873907
response = self.app.get(self.case_detail_url, user=self.user)
874908

875909
case = response.context.get("case")
@@ -1049,6 +1083,7 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m):
10491083
"new_docs": False,
10501084
"questions": [
10511085
make_contactmoment(self.contactmoment_new),
1086+
make_contactmoment(self.contactmoment_balie),
10521087
make_contactmoment(self.contactmoment_old),
10531088
],
10541089
},
@@ -1058,7 +1093,7 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m):
10581093
doc = PyQuery(response.text)
10591094
links = doc.find(".contactmomenten__link")
10601095

1061-
self.assertEqual(len(links), 2)
1096+
self.assertEqual(len(links), 3)
10621097
self.assertEqual(
10631098
links[0].attrib["href"],
10641099
reverse(
@@ -1068,6 +1103,13 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m):
10681103
)
10691104
self.assertEqual(
10701105
links[1].attrib["href"],
1106+
reverse(
1107+
"cases:kcm_redirect",
1108+
kwargs={"uuid": uuid_from_url(self.contactmoment_balie["url"])},
1109+
),
1110+
)
1111+
self.assertEqual(
1112+
links[2].attrib["href"],
10711113
reverse(
10721114
"cases:kcm_redirect",
10731115
kwargs={"uuid": uuid_from_url(self.contactmoment_old["url"])},

0 commit comments

Comments
 (0)