Skip to content

Commit

Permalink
[#2823] Filter contactmomenten on Mijn Vragen based on kanaal
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma authored and swrichards committed Oct 23, 2024
1 parent 0ee4d7d commit 20cd7ce
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from django.views.generic import FormView, TemplateView

from django_htmx.http import HttpResponseClientRedirect
from glom import glom
from mail_editor.helpers import find_template
from view_breadcrumbs import BaseBreadcrumbMixin
from zgw_consumers.api_models.constants import RolOmschrijving
Expand Down Expand Up @@ -163,6 +164,7 @@ def get_context_data(self, **kwargs):
self.store_statustype_mapping(self.case.zaaktype.identificatie)
self.store_resulttype_mapping(self.case.zaaktype.identificatie)

# questions/E-suite contactmomenten
objectcontactmomenten = []
if contactmoment_client := build_contactmomenten_client():
objectcontactmomenten = (
Expand All @@ -183,6 +185,15 @@ def get_context_data(self, **kwargs):
question, kcm_answer_mapping
)

# filter questions
openklant_config = OpenKlantConfig.get_solo()
if exclude_range := openklant_config.exclude_contactmoment_kanalen:
questions = [
item
for item in questions
if glom(item, "kanaal") not in exclude_range
]

statustypen = []
catalogi_client = api_group.catalogi_client
statustypen = catalogi_client.fetch_status_types_no_cache(
Expand Down
48 changes: 45 additions & 3 deletions src/open_inwoner/openzaak/tests/test_case_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,19 @@ def setUp(self):
antwoord="no",
onderwerp="e_suite_subject_code",
)
self.contactmoment_balie = generate_oas_component_cached(
"cmc",
"schemas/Contactmoment",
url=f"{CONTACTMOMENTEN_ROOT}contactmoment/aaaaaaaa-aaaa-aaaa-aaaa-cccccccccccc",
bronorganisatie="123456789",
identificatie="AB123",
registratiedatum="2024-09-27T03:39:28+00:00",
type="SomeType",
kanaal="Balie",
status=ContactMomentStatus.afgehandeld,
antwoord="no",
onderwerp="e_suite_subject_code",
)
self.objectcontactmoment_old = generate_oas_component_cached(
"cmc",
"schemas/Objectcontactmoment",
Expand All @@ -548,6 +561,14 @@ def setUp(self):
object_type="zaak",
contactmoment=self.contactmoment_new["url"],
)
self.objectcontactmoment_balie = generate_oas_component_cached(
"cmc",
"schemas/Objectcontactmoment",
url=f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten/bb51784c-fa2c-4f65-b24e-7179b615efac",
object=self.zaak["url"],
object_type="zaak",
contactmoment=self.contactmoment_balie["url"],
)
self.objectcontactmoment_eherkenning = generate_oas_component_cached(
"cmc",
"schemas/Objectcontactmoment",
Expand Down Expand Up @@ -625,8 +646,10 @@ def _setUpMocks(self, m, use_eindstatus=True):
self.status_type_finish,
self.contactmoment_old,
self.contactmoment_new,
self.contactmoment_balie,
self.objectcontactmoment_old,
self.objectcontactmoment_new,
self.objectcontactmoment_balie,
]:
m.get(resource["url"], json=resource)

Expand Down Expand Up @@ -707,7 +730,11 @@ def _setUpMocks(self, m, use_eindstatus=True):
m.get(
f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten?object={self.zaak['url']}",
json=paginated_response(
[self.objectcontactmoment_old, self.objectcontactmoment_new]
[
self.objectcontactmoment_old,
self.objectcontactmoment_new,
self.objectcontactmoment_balie,
]
),
)

Expand All @@ -719,7 +746,11 @@ def _setUpMocks(self, m, use_eindstatus=True):
m.get(
f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten?object={self.zaak['url']}",
json=paginated_response(
[self.objectcontactmoment_old, self.objectcontactmoment_new]
[
self.objectcontactmoment_old,
self.objectcontactmoment_new,
self.objectcontactmoment_balie,
]
),
)

Expand Down Expand Up @@ -870,6 +901,9 @@ def test_status_is_retrieved_when_user_logged_in_via_digid(
status_new_obj.statustype = factory(StatusType, self.status_type_new)
status_finish_obj.statustype = factory(StatusType, self.status_type_finish)

self.openklant_config.exclude_contactmoment_kanalen = ["Balie"]
self.openklant_config.save()

response = self.app.get(self.case_detail_url, user=self.user)

case = response.context.get("case")
Expand Down Expand Up @@ -1049,6 +1083,7 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m):
"new_docs": False,
"questions": [
make_contactmoment(self.contactmoment_new),
make_contactmoment(self.contactmoment_balie),
make_contactmoment(self.contactmoment_old),
],
},
Expand All @@ -1058,7 +1093,7 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m):
doc = PyQuery(response.text)
links = doc.find(".contactmomenten__link")

self.assertEqual(len(links), 2)
self.assertEqual(len(links), 3)
self.assertEqual(
links[0].attrib["href"],
reverse(
Expand All @@ -1068,6 +1103,13 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m):
)
self.assertEqual(
links[1].attrib["href"],
reverse(
"cases:kcm_redirect",
kwargs={"uuid": uuid_from_url(self.contactmoment_balie["url"])},
),
)
self.assertEqual(
links[2].attrib["href"],
reverse(
"cases:kcm_redirect",
kwargs={"uuid": uuid_from_url(self.contactmoment_old["url"])},
Expand Down

0 comments on commit 20cd7ce

Please sign in to comment.