Skip to content

Commit

Permalink
[#1788] Include submissions in cases
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Oct 11, 2023
1 parent 3e2e563 commit 347f098
Show file tree
Hide file tree
Showing 18 changed files with 169 additions and 326 deletions.
4 changes: 2 additions & 2 deletions src/open_inwoner/accounts/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ def test_non_digid_user_can_edit_profile(self):
form = edit_page.forms["profile-edit"]
form["first_name"] = "changed_first"
form["last_name"] = "changed_last"
response = form.submit()
form.submit()

user = User.objects.get(id=test_user.id)

Expand Down Expand Up @@ -994,7 +994,7 @@ def test_any_page_for_digid_user_redirect_to_necessary_fields(self):
urls = [
reverse("pages-root"),
reverse("products:category_list"),
reverse("cases:open_cases"),
reverse("cases:index"),
reverse("profile:detail"),
reverse("profile:data"),
reverse("collaborate:plan_list"),
Expand Down
17 changes: 1 addition & 16 deletions src/open_inwoner/cms/cases/tests/test_htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,22 +358,7 @@ def test_cases(self, m):
context = self.browser.new_context(storage_state=self.user_login_state)

page = context.new_page()
page.goto(self.live_reverse("cases:open_cases"))

# expected anchors
menu_items = page.get_by_role(
"complementary", name=_("Secundaire paginanavigatie")
).get_by_role("listitem")

expect(
menu_items.get_by_role("link", name=_("Openstaande aanvragen"))
).to_be_visible()
expect(
menu_items.get_by_role("link", name=_("Lopende aanvragen"))
).to_be_visible()
expect(
menu_items.get_by_role("link", name=_("Afgeronde aanvragen"))
).to_be_visible()
page.goto(self.live_reverse("cases:index"))

# case title
case_title = page.get_by_role("link", name=self.zaaktype["omschrijving"])
Expand Down
10 changes: 1 addition & 9 deletions src/open_inwoner/cms/cases/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,19 @@
KlantContactMomentListView,
)

from .views import ( # TODO: delete; TODO
from .views import (
CaseContactFormView,
CaseDocumentDownloadView,
CaseDocumentUploadFormView,
InnerCaseDetailView,
InnerCaseListView,
InnerOpenSubmissionListView,
OuterCaseDetailView,
OuterCaseListView,
OuterOpenSubmissionListView,
)

app_name = "cases"

urlpatterns = [
path("forms/", OuterOpenSubmissionListView.as_view(), name="open_submissions"),
path(
"forms/content/",
InnerOpenSubmissionListView.as_view(),
name="open_submissions_content",
),
path(
"contactmomenten/",
KlantContactMomentListView.as_view(),
Expand Down
1 change: 0 additions & 1 deletion src/open_inwoner/cms/cases/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
InnerCaseDetailView,
OuterCaseDetailView,
)
from .submissions import InnerOpenSubmissionListView, OuterOpenSubmissionListView
9 changes: 6 additions & 3 deletions src/open_inwoner/cms/cases/views/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from view_breadcrumbs import BaseBreadcrumbMixin

from open_inwoner.htmx.mixins import RequiresHtmxMixin
from open_inwoner.openzaak.formapi import fetch_open_submissions
from open_inwoner.utils.views import CommonPageMixin

from .mixins import CaseAccessMixin, CaseListMixin, OuterCaseAccessMixin


# TODO add OuterCaseAccessMixin back
class OuterCaseListView(
OuterCaseAccessMixin, CommonPageMixin, BaseBreadcrumbMixin, TemplateView
):
Expand All @@ -33,7 +33,6 @@ def get_context_data(self, **kwargs):
return context


# TODO: add CaseAccessMixin back
class InnerCaseListView(
RequiresHtmxMixin, CommonPageMixin, CaseAccessMixin, CaseListMixin, TemplateView
):
Expand All @@ -46,9 +45,13 @@ def page_title(self):

def get_cases(self):
cases = super().get_cases()
subs = fetch_open_submissions(self.request.user.bsn)

cases.sort(key=lambda case: case.startdatum, reverse=True)
return cases
subs.sort(key=lambda sub: sub.datum_laatste_wijziging, reverse=True)

all_cases = subs + cases
return all_cases

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
Expand Down
43 changes: 30 additions & 13 deletions src/open_inwoner/cms/cases/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,32 @@ def process_cases(self, cases: List[Zaak]) -> List[dict]:

updated_cases = []
for case in cases:
case_dict = {
"identificatie": format_zaak_identificatie(case.identificatie, config),
"uuid": str(case.uuid),
"start_date": case.startdatum,
"end_date": getattr(case, "einddatum", None),
"description": case.zaaktype.omschrijving,
"current_status": status_translate.from_glom(
case, "status.statustype.omschrijving", default=""
),
}
updated_cases.append(case_dict)
try:
# cases
case_dict = {
"identificatie": format_zaak_identificatie(
case.identificatie, config
),
"uuid": str(case.uuid),
"start_date": case.startdatum,
"end_date": getattr(case, "einddatum", None),
"description": case.zaaktype.omschrijving,
"current_status": status_translate.from_glom(
case, "status.statustype.omschrijving", default=""
),
}
updated_cases.append(case_dict)
except AttributeError:
# submissions are now cases too
case_dict = {
"url": case.url,
"uuid": case.uuid,
"naam": case.naam,
"vervolg_link": case.vervolg_link,
"datum_laatste_wijziging": case.datum_laatste_wijziging,
"eind_datum_geldigheid": case.eind_datum_geldigheid,
}
updated_cases.append(case_dict)
return updated_cases

def get_context_data(self, **kwargs):
Expand All @@ -169,9 +184,11 @@ def get_context_data(self, **kwargs):
context.update(paginator_dict)

for case in cases:
self.log_case_access(case["identificatie"])
try:
self.log_case_access(case["identificatie"])
except KeyError:
self.log_case_access(f"{case['naam']}: {case['uuid']}")

context["anchors"] = self.get_anchors()
return context

def get_anchors(self) -> list:
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class OuterCaseDetailView(
@cached_property
def crumbs(self):
return [
(_("Mijn aanvragen"), reverse("cases:open_cases")),
(_("Mijn aanvragen"), reverse("cases:index")),
(
_("Status"),
reverse("cases:case_detail", kwargs=self.kwargs),
Expand All @@ -95,7 +95,7 @@ class InnerCaseDetailView(
@cached_property
def crumbs(self):
return [
(_("Mijn aanvragen"), reverse("cases:open_cases")),
(_("Mijn aanvragen"), reverse("cases:index")),
(
_("Status"),
reverse("cases:case_detail", kwargs=self.kwargs),
Expand Down
72 changes: 0 additions & 72 deletions src/open_inwoner/cms/cases/views/submissions.py

This file was deleted.

3 changes: 1 addition & 2 deletions src/open_inwoner/openzaak/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
from simple_certmanager.constants import CertificateTypes
from simple_certmanager.models import Certificate
from zgw_consumers.api_models.base import factory as zwg_factory
from zgw_consumers.api_models.catalogi import InformatieObjectType
from zgw_consumers.api_models.constants import RolOmschrijving
from zgw_consumers.models import Service
from zgw_consumers.test import generate_oas_component

from open_inwoner.accounts.tests.factories import UserFactory
from open_inwoner.openzaak.api_models import Notification, Rol, ZaakType
from open_inwoner.openzaak.api_models import Notification, Rol
from open_inwoner.openzaak.models import (
CatalogusConfig,
StatusTranslation,
Expand Down
42 changes: 42 additions & 0 deletions src/open_inwoner/openzaak/tests/mocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from zgw_consumers.test import mock_service_oas_get

from open_inwoner.openzaak.tests.shared import FORMS_ROOT


class ESuiteData:
def __init__(self):
self.submission_1 = {
"url": "https://dmidoffice2.esuite-development.net/formulieren-provider/api/v1/8e3ae29c-7bc5-4f7d-a27c-b0c83c13328e",
"uuid": "8e3ae29c-7bc5-4f7d-a27c-b0c83c13328e",
"naam": "Melding openbare ruimte",
"vervolgLink": "https://dloket2.esuite-development.net/formulieren-nieuw/formulier/start/8e3ae29c-7bc5-4f7d-a27c-b0c83c13328e",
"datumLaatsteWijziging": "2023-02-13T14:02:00.999+01:00",
"eindDatumGeldigheid": "2023-05-14T14:02:00.999+02:00",
}
self.submission_2 = {
"url": "https://dmidoffice2.esuite-development.net/formulieren-provider/api/v1/d14658b0-dcb4-4d3c-a61c-fd7d0c78f296",
"uuid": "d14658b0-dcb4-4d3c-a61c-fd7d0c78f296",
"naam": "Indienen bezwaarschrift",
"vervolgLink": "https://dloket2.esuite-development.net/formulieren-nieuw/formulier/start/d14658b0-dcb4-4d3c-a61c-fd7d0c78f296",
"datumLaatsteWijziging": "2023-02-13T14:10:26.197000+0100",
"eindDatumGeldigheid": "2023-05-14T14:10:26.197+02:00",
}
# note this is a weird esuite response without pagination links
self.response = {
"count": 2,
"results": [
self.submission_1,
self.submission_2,
],
}

def setUpOASMocks(self, m):
mock_service_oas_get(m, FORMS_ROOT, "submissions-esuite")

def install_mocks(self, m):
self.setUpOASMocks(m)
m.get(
f"{FORMS_ROOT}openstaande-inzendingen",
json=self.response,
)
return self
Loading

0 comments on commit 347f098

Please sign in to comment.