diff --git a/src/open_inwoner/accounts/views/contactmoments.py b/src/open_inwoner/accounts/views/contactmoments.py index 25fa06720e..c5f0373a58 100644 --- a/src/open_inwoner/accounts/views/contactmoments.py +++ b/src/open_inwoner/accounts/views/contactmoments.py @@ -3,11 +3,12 @@ from typing import Optional, TypedDict from django.contrib.auth.mixins import AccessMixin -from django.http import Http404 +from django.http import Http404, HttpResponseRedirect from django.shortcuts import redirect from django.urls import reverse from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ +from django.views import View from django.views.generic import TemplateView from view_breadcrumbs import BaseBreadcrumbMixin @@ -211,3 +212,31 @@ def get_context_data(self, **kwargs): }, ] return ctx + + +class KlantContactMomentRedirectView(KlantContactMomentAccessMixin, View): + """ + Redirect to `KlantContactMomentDetailView` on the basis of contactmoment uuid + """ + + def get(self, request, *args, **kwargs): + klanten_client = build_client("klanten") + contactmoment_client = build_client("contactmomenten") + + klant = klanten_client.retrieve_klant(**get_fetch_parameters(self.request)) + kcms = contactmoment_client.retrieve_klantcontactmomenten_for_klant(klant) + + if not kcms: + raise Http404 + + contactmoment_uuid = kwargs["uuid"] + kcm = next( + (kcm for kcm in kcms if str(kcm.contactmoment.uuid) == contactmoment_uuid) + ) + + if not kcm: + raise Http404 + + return HttpResponseRedirect( + reverse("cases:contactmoment_detail", kwargs={"kcm_uuid": kcm.uuid}) + ) diff --git a/src/open_inwoner/cms/cases/tests/test_contactform.py b/src/open_inwoner/cms/cases/tests/test_contactform.py index 6f9affff3f..7063302376 100644 --- a/src/open_inwoner/cms/cases/tests/test_contactform.py +++ b/src/open_inwoner/cms/cases/tests/test_contactform.py @@ -19,6 +19,7 @@ DigidUserFactory, eHerkenningUserFactory, ) +from open_inwoner.openklant.clients import ContactmomentenClient from open_inwoner.openklant.constants import Status from open_inwoner.openklant.models import OpenKlantConfig from open_inwoner.openklant.tests.data import CONTACTMOMENTEN_ROOT, KLANTEN_ROOT @@ -41,6 +42,9 @@ @requests_mock.Mocker() +@patch.object( + ContactmomentenClient, "retrieve_objectcontactmomenten_for_zaak", autospec=True +) @override_settings( ROOT_URLCONF="open_inwoner.cms.tests.urls", MIDDLEWARE=PATCHED_MIDDLEWARE ) @@ -326,14 +330,11 @@ def _setUpExtraMocks(self, m): json=self.contactmoment, ) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_form_is_shown_if_open_klant_api_configured(self, m, ocm_mock): + def test_form_is_shown_if_open_klant_api_configured(self, m, contactmoment_mock): self._setUpMocks(m) self._setUpExtraMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] self.assertTrue(self.ok_config.has_api_configuration()) @@ -343,14 +344,11 @@ def test_form_is_shown_if_open_klant_api_configured(self, m, ocm_mock): self.assertTrue(response.context["case"]["contact_form_enabled"]) self.assertTrue(contact_form) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_form_is_shown_if_open_klant_email_configured(self, m, ocm_mock): + def test_form_is_shown_if_open_klant_email_configured(self, m, contactmoment_mock): self._setUpMocks(m) self._setUpExtraMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] self.ok_config.register_email = "example@example.com" self.ok_config.register_contact_moment = False @@ -365,14 +363,13 @@ def test_form_is_shown_if_open_klant_email_configured(self, m, ocm_mock): self.assertTrue(response.context["case"]["contact_form_enabled"]) self.assertTrue(contact_form) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_form_is_shown_if_open_klant_email_and_api_configured(self, m, ocm_mock): + def test_form_is_shown_if_open_klant_email_and_api_configured( + self, m, contactmoment_mock + ): self._setUpMocks(m) self._setUpExtraMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] self.ok_config.register_email = "example@example.com" self.ok_config.save() @@ -386,9 +383,11 @@ def test_form_is_shown_if_open_klant_email_and_api_configured(self, m, ocm_mock) self.assertTrue(response.context["case"]["contact_form_enabled"]) self.assertTrue(contact_form) - def test_no_form_shown_if_open_klant_not_configured(self, m): + def test_no_form_shown_if_open_klant_not_configured(self, m, contactmoment_mock): self._setUpMocks(m) + contactmoment_mock.return_value = [] + # reset self.ok_config.klanten_service = None self.ok_config.contactmomenten_service = None @@ -406,15 +405,10 @@ def test_no_form_shown_if_open_klant_not_configured(self, m): self.assertFalse(response.context["case"]["contact_form_enabled"]) self.assertFalse(contact_form) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_no_form_shown_if_contact_form_disabled(self, m, ocm_mock): + def test_no_form_shown_if_contact_form_disabled(self, m, contactmoment_mock): self._setUpMocks(m) self._setUpExtraMocks(m) - ocm_mock.return_value = [] - CatalogusConfig.objects.all().delete() self.zaak_type_config.delete() self.zaak_type_config = ZaakTypeConfigFactory( @@ -429,14 +423,11 @@ def test_no_form_shown_if_contact_form_disabled(self, m, ocm_mock): self.assertFalse(response.context["case"]["contact_form_enabled"]) self.assertFalse(contact_form) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_form_success_with_api(self, m, ocm_mock): + def test_form_success_with_api(self, m, contactmoment_mock): self._setUpMocks(m) self._setUpExtraMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] response = self.app.get(self.case_detail_url, user=self.user) form = response.forms["contact-form"] @@ -470,14 +461,11 @@ def test_form_success_with_api(self, m, ocm_mock): }, ) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_form_success_with_api_eherkenning_user(self, m, ocm_mock): + def test_form_success_with_api_eherkenning_user(self, m, contactmoment_mock): self._setUpMocks(m) self._setUpExtraMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] for use_rsin_for_innNnpId_query_parameter in [True, False]: with self.subTest( @@ -540,14 +528,11 @@ def test_form_success_with_api_eherkenning_user(self, m, ocm_mock): }, ) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_form_success_with_email(self, m, ocm_mock): + def test_form_success_with_email(self, m, contactmoment_mock): self._setUpMocks(m) self._setUpExtraMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] self.ok_config.register_email = "example@example.com" self.ok_config.register_contact_moment = False @@ -578,14 +563,11 @@ def test_form_success_with_email(self, m, ocm_mock): _("Contact formulier inzending vanaf Open Inwoner Platform"), ) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_form_success_with_bearth_email_and_api(self, m, ocm_mock): + def test_form_success_with_both_email_and_api(self, m, contactmoment_mock): self._setUpMocks(m) self._setUpExtraMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] self.ok_config.register_email = "example@example.com" self.ok_config.save() diff --git a/src/open_inwoner/cms/cases/tests/test_htmx.py b/src/open_inwoner/cms/cases/tests/test_htmx.py index d0d77bb090..d74b371446 100644 --- a/src/open_inwoner/cms/cases/tests/test_htmx.py +++ b/src/open_inwoner/cms/cases/tests/test_htmx.py @@ -17,6 +17,7 @@ from open_inwoner.accounts.tests.factories import DigidUserFactory from open_inwoner.cms.tests import cms_tools from open_inwoner.configurations.models import SiteConfiguration +from open_inwoner.openklant.clients import ContactmomentenClient from open_inwoner.openklant.constants import Status from open_inwoner.openklant.models import OpenKlantConfig from open_inwoner.openklant.tests.data import CONTACTMOMENTEN_ROOT, KLANTEN_ROOT @@ -44,6 +45,9 @@ @tag("e2e") @requests_mock.Mocker() +@patch.object( + ContactmomentenClient, "retrieve_objectcontactmomenten_for_zaak", autospec=True +) @override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls") class CasesPlaywrightTests( AssertMockMatchersMixin, @@ -407,13 +411,10 @@ def _setUpMocks(self, m): ), ] - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_cases(self, m, ocm_mock): + def test_cases(self, m, contactmoment_mock): self._setUpMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] context = self.browser.new_context(storage_state=self.user_login_state) @@ -505,13 +506,10 @@ def test_cases(self, m, ocm_mock): # finally check if our mock matchers are accurate self.assertMockMatchersCalled(self.matchers) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" - ) - def test_multiple_file_upload(self, m, ocm_mock): + def test_multiple_file_upload(self, m, contactmoment_mock): self._setUpMocks(m) - ocm_mock.return_value = [] + contactmoment_mock.return_value = [] # Keep track of uploaded files (schemas/EnkelvoudigInformatieObject array) # This list is updated by mocks after uploading the files. diff --git a/src/open_inwoner/cms/cases/urls.py b/src/open_inwoner/cms/cases/urls.py index 241e991c6f..e15e779d93 100644 --- a/src/open_inwoner/cms/cases/urls.py +++ b/src/open_inwoner/cms/cases/urls.py @@ -3,6 +3,7 @@ from open_inwoner.accounts.views.contactmoments import ( KlantContactMomentDetailView, KlantContactMomentListView, + KlantContactMomentRedirectView, ) from .views import ( @@ -11,7 +12,6 @@ CaseDocumentUploadFormView, InnerCaseDetailView, InnerCaseListView, - KCMRedirectView, OuterCaseDetailView, OuterCaseListView, ) @@ -31,7 +31,7 @@ ), path( "contactmoment//", - KCMRedirectView.as_view(), + KlantContactMomentRedirectView.as_view(), name="kcm_redirect", ), path( diff --git a/src/open_inwoner/cms/cases/views/__init__.py b/src/open_inwoner/cms/cases/views/__init__.py index b258a60981..29832011c4 100644 --- a/src/open_inwoner/cms/cases/views/__init__.py +++ b/src/open_inwoner/cms/cases/views/__init__.py @@ -4,7 +4,6 @@ CaseDocumentDownloadView, CaseDocumentUploadFormView, InnerCaseDetailView, - KCMRedirectView, OuterCaseDetailView, ) @@ -16,5 +15,4 @@ "CaseDocumentUploadFormView", "InnerCaseDetailView", "OuterCaseDetailView", - "KCMRedirectView", ] diff --git a/src/open_inwoner/cms/cases/views/status.py b/src/open_inwoner/cms/cases/views/status.py index 8256da2435..3fda7c1c9b 100644 --- a/src/open_inwoner/cms/cases/views/status.py +++ b/src/open_inwoner/cms/cases/views/status.py @@ -8,7 +8,7 @@ from django.conf import settings from django.contrib import messages from django.core.exceptions import ObjectDoesNotExist, PermissionDenied -from django.http import Http404, HttpResponseRedirect, StreamingHttpResponse +from django.http import Http404, StreamingHttpResponse from django.urls import reverse from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ @@ -20,12 +20,7 @@ from view_breadcrumbs import BaseBreadcrumbMixin from zgw_consumers.api_models.constants import RolOmschrijving -from open_inwoner.accounts.views.contactmoments import KlantContactMomentAccessMixin -from open_inwoner.openklant.api_models import ObjectContactMoment -from open_inwoner.openklant.clients import ( - ContactmomentenClient, - build_client as build_client_openklant, -) +from open_inwoner.openklant.clients import build_client as build_client_openklant from open_inwoner.openklant.models import OpenKlantConfig from open_inwoner.openklant.wrap import get_fetch_parameters from open_inwoner.openzaak.api_models import Status, StatusType, Zaak @@ -139,17 +134,58 @@ def get_context_data(self, **kwargs): status_translate = StatusTranslation.objects.get_lookup() zaken_client = build_client_openzaak("zaak") - contactmoment_client = build_client_openklant("contactmomenten") # fetch data associated with `self.case` documents = self.get_case_document_files(self.case, zaken_client) statuses = zaken_client.fetch_status_history(self.case.url) - objectcontactmomenten = self.get_objectcontactmomenten( - client=contactmoment_client - ) self.store_statustype_mapping(self.case.zaaktype.identificatie) self.store_resulttype_mapping(self.case.zaaktype.identificatie) + # TODO: restore + # objectcontactmomenten = [] + # if contactmoment_client := build_client_openklant("contactmomenten"): + # objectcontactmomenten = ( + # contactmoment_client.retrieve_objectcontactmomenten_for_zaak( + # self.case + # ) + # ) + # questions = [ocm.contactmoment for ocm in objectcontactmomenten] + # from .. import dev_snippets + # questions = dev_snippets.contactmomenten_stubs() + + # TODO: remove + import datetime + + import django_yubin + from zgw_consumers.api_models.base import factory + + from open_inwoner.openklant.api_models import ContactMoment + + questions = [] + for i in range(10): + data = { + "url": "https://contactmomenten.nl/api/v1/contactmoment/aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbb2", + "bronorganisatie": "Zbw", + "registratiedatum": datetime.datetime(1985 + i, 12, 2, 0, 51, 24), + "kanaal": "Contactformulier", + "tekst": "Lorem ipsum dolor sit amet?", + "medewerker_identificatie": None, + "identificatie": "AB123", + "type": "SomeType", + "onderwerp": "e_suite_subject_code", + "status": "afgehandeld", + "antwoord": "yes", + "voorkeurskanaal": "sZCjHWnImiafznWmnrFlHYCpEqIyysxDxOCHnKrslJYkZuADJE", + "voorkeurstaal": "Avo", + "vorig_contactmoment": None, + "volgend_contactmoment": None, + "onderwerp_links": ["https://www.kramer.biz/"], + "initiatiefnemer": "klant", + "medewerker": "https://davis.com/", + } + questions.append(factory(ContactMoment, data)) + questions.sort(key=lambda q: q.registratiedatum, reverse=True) + statustypen = [] if catalogi_client := build_client_openzaak("catalogi"): statustypen = catalogi_client.fetch_status_types_no_cache( @@ -210,7 +246,7 @@ def get_context_data(self, **kwargs): "created", dt.timedelta(days=settings.DOCUMENT_RECENT_DAYS), ), - "questions": [ocm.contactmoment for ocm in objectcontactmomenten], + "questions": questions, } context["case"].update(self.get_upload_info_context(self.case)) context["anchors"] = self.get_anchors(statuses, documents) @@ -618,14 +654,6 @@ def get_case_document_files(case: Zaak, client: ZakenClient) -> List[SimpleFile] except TypeError: return documents - def get_objectcontactmomenten( - self, - client: Optional[ContactmomentenClient], - ) -> list[ObjectContactMoment]: - if not client: - return [] - return client.retrieve_objectcontactmomenten_for_zaak(self.case) - def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs["case"] = self.case @@ -643,38 +671,6 @@ def get_anchors(self, statuses, documents): return anchors -class KCMRedirectView(KlantContactMomentAccessMixin, View): - """ - Redirect to `KlantContactMomentDetailView` on the basis of contactmoment uuid - - Case-related questions ("objectcontactmomenten") in the template contain links - to the contactmoment detail under "mijn-aanvragen/contactmomenten". For this, - we need to fetch the klantcontactomment uuid and pass it to the relevant view. - """ - - def get(self, request, *args, **kwargs): - klanten_client = build_client_openklant("klanten") - contactmoment_client = build_client_openklant("contactmomenten") - - klant = klanten_client.retrieve_klant(**get_fetch_parameters(self.request)) - kcms = contactmoment_client.retrieve_klantcontactmomenten_for_klant(klant) - - if not kcms: - raise Http404 - - contactmoment_uuid = kwargs["uuid"] - kcm = next( - (kcm for kcm in kcms if str(kcm.contactmoment.uuid) == contactmoment_uuid) - ) - - if not kcm: - raise Http404 - - return HttpResponseRedirect( - reverse("cases:contactmoment_detail", kwargs={"kcm_uuid": kcm.uuid}) - ) - - class CaseDocumentDownloadView(LogMixin, CaseAccessMixin, View): def get(self, request, *args, **kwargs): if not self.case: diff --git a/src/open_inwoner/js/components/card/ToggleHideSelection.js b/src/open_inwoner/js/components/card/ToggleHideSelection.js index 766417245e..d4a535c776 100644 --- a/src/open_inwoner/js/components/card/ToggleHideSelection.js +++ b/src/open_inwoner/js/components/card/ToggleHideSelection.js @@ -1,42 +1,56 @@ export class ToggleHideSelection { - static selector = '.card' + static selector = '.card--toggle-hide' constructor(node) { this.node = node + this.icon = document.querySelector('.expand-icon') this.button = document.querySelector('#toggle-hide-elements') - this.button?.addEventListener('click', this.toggleHide.bind(this)) - this.icon = document.querySelector('.readmore__icon') - this.node.showMoreText = document.querySelector( - '.showmore__button-text' - ).textContent - - // hide all but the first 3 cards by default - var allCards = document.querySelectorAll('.card') - var cardsTail = Array.from(allCards).slice(3) - cardsTail.forEach((element) => { - element.classList.add('hide-me') - }) + this.button.addEventListener('click', this.toggleHide.bind(this)) + this.button.innerHTML = + this.icon.outerHTML + this.button.dataset.labelReveal + + // hide all but the first 3 cards by default (or hide button/icon if there are at most 3 cards) + const allCards = document.querySelectorAll(ToggleHideSelection.selector) + const cardsTail = Array.from(allCards).slice(3) + + if (cardsTail.length == 0) { + this.button.classList.add('hide-me') + } else { + cardsTail.forEach((element) => { + element.classList.add('hide-me') + }) + } } toggleHide() { - var allCards = document.querySelectorAll('.card') - var cardsTail = Array.from(allCards).slice(3) + const allCards = document.querySelectorAll(ToggleHideSelection.selector) + const cardsTail = Array.from(allCards).slice(3) - cardsTail.forEach((e) => { + cardsTail.forEach((element) => { this.node.classList.toggle('hide-me') }) + this.icon.textContent = 'expand_less' + this.button.innerHTML = + this.icon.outerHTML + this.button.dataset.labelCollapse + // toggle button text + icon - for (var i = 0; i < cardsTail.length; i++) { - if (cardsTail[i].classList.contains('hide-me')) { - this.icon.textContent = 'expand_more' - this.button.innerHTML = this.icon.outerHTML + this.node.showMoreText - break - } else { - this.icon.textContent = 'expand_less' - this.button.innerHTML = this.icon.outerHTML + 'Minder toon' - break - } + function containsHiddenElements(data) { + return data.some(function (e) { + return e.classList.contains('hide-me') + }) + } + + if (containsHiddenElements(cardsTail)) { + console.log('hidden') + this.icon.textContent = 'expand_more' + this.button.innerHTML = + this.icon.outerHTML + this.button.dataset.labelReveal + } else { + console.log('not hidden') + this.icon.textContent = 'expand_less' + this.button.innerHTML = + this.icon.outerHTML + this.button.dataset.labelCollapse } } } diff --git a/src/open_inwoner/openzaak/tests/test_case_detail.py b/src/open_inwoner/openzaak/tests/test_case_detail.py index 154b40bcac..d51afdab92 100644 --- a/src/open_inwoner/openzaak/tests/test_case_detail.py +++ b/src/open_inwoner/openzaak/tests/test_case_detail.py @@ -26,6 +26,7 @@ from open_inwoner.accounts.choices import LoginTypeChoices from open_inwoner.accounts.tests.factories import UserFactory, eHerkenningUserFactory from open_inwoner.cms.cases.views.status import InnerCaseDetailView, SimpleFile +from open_inwoner.openklant.clients import ContactmomentenClient from open_inwoner.openklant.constants import Status as ContactMomentStatus from open_inwoner.openklant.models import OpenKlantConfig from open_inwoner.openklant.tests.factories import make_contactmoment @@ -464,12 +465,13 @@ def setUp(self): # # contactmomenten # - self.contactmoment = generate_oas_component_cached( + self.contactmoment_old = generate_oas_component_cached( "cmc", "schemas/ContactMoment", uuid="aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb", url=f"{CONTACTMOMENTEN_ROOT}contactmoment/aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb", identificatie="AB123", + registratiedatum="1971-07-17T20:15:07+00:00", type="SomeType", kanaal="Contactformulier", status=ContactMomentStatus.afgehandeld, @@ -477,35 +479,36 @@ def setUp(self): antwoord="Nee", onderwerp="e_suite_subject_code", ) - self.contactmoment2 = generate_oas_component_cached( + self.contactmoment_new = generate_oas_component_cached( "cmc", "schemas/ContactMoment", uuid="aaaaaaaa-aaaa-aaaa-aaaa-dddddddddddd", url=f"{CONTACTMOMENTEN_ROOT}contactmoment/aaaaaaaa-aaaa-aaaa-aaaa-dddddddddddd", identificatie="AB123", + registratiedatum="1972-09-27T03:39:28+00:00", type="SomeType", kanaal="MAIL", status=ContactMomentStatus.afgehandeld, antwoord="no", onderwerp="e_suite_subject_code", ) - self.objectcontactmoment = generate_oas_component_cached( + self.objectcontactmoment_old = generate_oas_component_cached( "cmc", "schemas/ObjectContactMoment", uuid="77880671-b88a-44ed-ba24-dc2ae688c2ec", url=f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten/77880671-b88a-44ed-ba24-dc2ae688c2ec", object=self.zaak["url"], object_type="zaak", - contactmoment=self.contactmoment["url"], + contactmoment=self.contactmoment_old["url"], ) - self.objectcontactmoment2 = generate_oas_component_cached( + self.objectcontactmoment_new = generate_oas_component_cached( "cmc", "schemas/ObjectContactMoment", uuid="bb51784c-fa2c-4f65-b24e-7179b615efac", url=f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten/bb51784c-fa2c-4f65-b24e-7179b615efac", object=self.zaak["url"], object_type="zaak", - contactmoment=self.contactmoment2["url"], + contactmoment=self.contactmoment_new["url"], ) self.objectcontactmoment_eherkenning = generate_oas_component_cached( "cmc", @@ -514,7 +517,7 @@ def setUp(self): url=f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten/bb51784c-fa2c-4f65-b24e-7179b615efac", object=self.zaak_eherkenning["url"], object_type="zaak", - contactmoment=self.contactmoment["url"], + contactmoment=self.contactmoment_old["url"], ) # # documents @@ -578,10 +581,10 @@ def _setUpMocks(self, m, use_eindstatus=True): self.status_type_new, self.status_type_in_behandeling, self.status_type_finish, - self.contactmoment, - self.contactmoment2, - self.objectcontactmoment, - self.objectcontactmoment2, + self.contactmoment_old, + self.contactmoment_new, + self.objectcontactmoment_old, + self.objectcontactmoment_new, ]: m.get(resource["url"], json=resource) @@ -662,7 +665,7 @@ def _setUpMocks(self, m, use_eindstatus=True): m.get( f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten?object={self.zaak['url']}", json=paginated_response( - [self.objectcontactmoment, self.objectcontactmoment2] + [self.objectcontactmoment_old, self.objectcontactmoment_new] ), ) @@ -674,7 +677,7 @@ def _setUpMocks(self, m, use_eindstatus=True): m.get( f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten?object={self.zaak['url']}", json=paginated_response( - [self.objectcontactmoment, self.objectcontactmoment2] + [self.objectcontactmoment_old, self.objectcontactmoment_new] ), ) @@ -768,8 +771,8 @@ def test_status_is_retrieved_when_user_logged_in_via_digid( "contact_form_enabled": False, "new_docs": False, "questions": [ - make_contactmoment(self.contactmoment), - make_contactmoment(self.contactmoment2), + make_contactmoment(self.contactmoment_new), + make_contactmoment(self.contactmoment_old), ], }, ) @@ -777,18 +780,22 @@ def test_status_is_retrieved_when_user_logged_in_via_digid( mock_hook_status.assert_called_once() mock_hook_documents.assert_called_once() - # check question links + # check question links (should be ordered by contactmoment: recent first) doc = PyQuery(response.text) links = doc.find(".contactmomenten__link") self.assertEqual(len(links), 2) self.assertEqual( links[0].attrib["href"], - reverse("cases:kcm_redirect", kwargs={"uuid": self.contactmoment["uuid"]}), + reverse( + "cases:kcm_redirect", kwargs={"uuid": self.contactmoment_new["uuid"]} + ), ) self.assertEqual( links[1].attrib["href"], - reverse("cases:kcm_redirect", kwargs={"uuid": self.contactmoment2["uuid"]}), + reverse( + "cases:kcm_redirect", kwargs={"uuid": self.contactmoment_old["uuid"]} + ), ) def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m): @@ -876,24 +883,28 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m): "contact_form_enabled": False, "new_docs": False, "questions": [ - make_contactmoment(self.contactmoment), - make_contactmoment(self.contactmoment2), + make_contactmoment(self.contactmoment_new), + make_contactmoment(self.contactmoment_old), ], }, ) - # check question links + # check question links (should be ordered by contactmoment: recent first) doc = PyQuery(response.text) links = doc.find(".contactmomenten__link") self.assertEqual(len(links), 2) self.assertEqual( links[0].attrib["href"], - reverse("cases:kcm_redirect", kwargs={"uuid": self.contactmoment["uuid"]}), + reverse( + "cases:kcm_redirect", kwargs={"uuid": self.contactmoment_new["uuid"]} + ), ) self.assertEqual( links[1].attrib["href"], - reverse("cases:kcm_redirect", kwargs={"uuid": self.contactmoment2["uuid"]}), + reverse( + "cases:kcm_redirect", kwargs={"uuid": self.contactmoment_old["uuid"]} + ), ) def test_second_status_preview(self, m): @@ -1268,14 +1279,12 @@ def test_page_displays_expected_data(self, m): self.assertContains(response, "Coffee zaaktype") self.assertContains(response, "uploaded_document_title") - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" + @patch.object( + ContactmomentenClient, "retrieve_objectcontactmomenten_for_zaak", autospec=True ) - def test_page_displays_expected_data_for_eherkenning_user(self, m, ocm_mock): + def test_page_displays_expected_data_for_eherkenning_user(self, m, cm_client_mock): self._setUpMocks(m) - ocm_mock.return_value = [] - for fetch_eherkenning_zaken_with_rsin in [True, False]: with self.subTest( fetch_eherkenning_zaken_with_rsin=fetch_eherkenning_zaken_with_rsin @@ -1294,11 +1303,11 @@ def test_page_displays_expected_data_for_eherkenning_user(self, m, ocm_mock): self.assertContains(response, "Coffee zaaktype") @set_kvk_branch_number_in_session("1234") - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" + @patch.object( + ContactmomentenClient, "retrieve_objectcontactmomenten_for_zaak", autospec=True ) def test_page_displays_expected_data_for_eherkenning_user_with_vestigingsnummer( - self, m, ocm_mock + self, m, cm_client_mock ): """ In order to have access to a case detail page when logged in as a specific @@ -1320,8 +1329,6 @@ def test_page_displays_expected_data_for_eherkenning_user_with_vestigingsnummer( ), ) - ocm_mock.return_value = [] - for fetch_eherkenning_zaken_with_rsin in [True, False]: with self.subTest( fetch_eherkenning_zaken_with_rsin=fetch_eherkenning_zaken_with_rsin @@ -1376,16 +1383,14 @@ def test_when_accessing_case_detail_a_timelinelog_is_created(self, m): self.assertEqual(self.user, log.user) self.assertEqual(self.user, log.content_object) - @patch( - "open_inwoner.cms.cases.views.status.InnerCaseDetailView.get_objectcontactmomenten" + @patch.object( + ContactmomentenClient, "retrieve_objectcontactmomenten_for_zaak", autospec=True ) def test_case_io_objects_are_retrieved_when_user_logged_in_via_digid( - self, m, ocm_mock + self, m, cm_client_mock ): self._setUpMocks(m) - ocm_mock.return_value = [] - response = self.app.get(self.case_detail_url, user=self.user) documents = response.context.get("case", {}).get("documents") self.assertEquals(len(documents), 2) @@ -2257,7 +2262,7 @@ def test_kcm_redirect(self, m): uuid="aaaaaaaa-aaaa-aaaa-aaaa-cccccccccccc", url=f"{CONTACTMOMENTEN_ROOT}klantcontactmomenten/aaaaaaaa-aaaa-aaaa-aaaa-cccccccccccc", klant=klant["url"], - contactmoment=self.contactmoment["url"], + contactmoment=self.contactmoment_old["url"], ) m.get( @@ -2273,15 +2278,17 @@ def test_kcm_redirect(self, m): json=paginated_response([klant_contactmoment]), ) m.get( - f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten?contactmoment={self.contactmoment['url']}", - json=paginated_response([self.objectcontactmoment]), + f"{CONTACTMOMENTEN_ROOT}objectcontactmomenten?contactmoment={self.contactmoment_old['url']}", + json=paginated_response([self.objectcontactmoment_old]), ) # # asserts # response = self.app.get( - reverse("cases:kcm_redirect", kwargs={"uuid": self.contactmoment["uuid"]}), + reverse( + "cases:kcm_redirect", kwargs={"uuid": self.contactmoment_old["uuid"]} + ), user=self.user, ) self.assertRedirects( diff --git a/src/open_inwoner/scss/components/Card/Card.scss b/src/open_inwoner/scss/components/Card/Card.scss index f9e37f9b0c..a0eff8927a 100644 --- a/src/open_inwoner/scss/components/Card/Card.scss +++ b/src/open_inwoner/scss/components/Card/Card.scss @@ -1,5 +1,5 @@ .hide-me { - display: none; + display: none !important; } .card { @@ -15,7 +15,7 @@ border: var(--card-size-border) solid var(--card-color-border); border-radius: var(--border-radius); box-sizing: border-box; - // display: flex; + display: flex; flex-direction: column; min-height: 70px; min-width: var(--header-height); diff --git a/src/open_inwoner/scss/components/Contactmomenten/Contactmomenten.scss b/src/open_inwoner/scss/components/Contactmomenten/Contactmomenten.scss index 8647068e1b..0008d2d95f 100644 --- a/src/open_inwoner/scss/components/Contactmomenten/Contactmomenten.scss +++ b/src/open_inwoner/scss/components/Contactmomenten/Contactmomenten.scss @@ -64,11 +64,8 @@ } } - /// cards on cases page - .card { - .contactmomenten__link { - text-decoration: none; - } + .contactmomenten__link { + text-decoration: none; } &__title { diff --git a/src/open_inwoner/templates/pages/cases/status_inner.html b/src/open_inwoner/templates/pages/cases/status_inner.html index a9adea2320..38a49b3b5c 100644 --- a/src/open_inwoner/templates/pages/cases/status_inner.html +++ b/src/open_inwoner/templates/pages/cases/status_inner.html @@ -1,4 +1,4 @@ -{% load i18n utils anchor_menu_tags card_tags file_tags grid_tags list_tags table_tags solo_tags link_tags button_tags icon_tags notification_tags pagination_tags %} +{% load i18n utils anchor_menu_tags card_tags file_tags grid_tags table_tags solo_tags link_tags button_tags icon_tags notification_tags %} {# Messages #}
@@ -77,12 +77,9 @@

{% tran {% if case.questions %} {% include "pages/questions/questions.html" with questions=case.questions only %} {% endif %} diff --git a/src/open_inwoner/templates/pages/questions/questions.html b/src/open_inwoner/templates/pages/questions/questions.html index 9b85da33d9..e24ea5974c 100644 --- a/src/open_inwoner/templates/pages/questions/questions.html +++ b/src/open_inwoner/templates/pages/questions/questions.html @@ -3,35 +3,34 @@