Skip to content

Commit

Permalink
[#2996] Retrieve questions linked to a zaak with OpenKlant
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schilling committed Jan 31, 2025
1 parent db9980d commit a6d8b4a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/open_inwoner/cms/cases/views/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def resolve_case(self, case: Zaak, group: ZGWApiGroupConfig) -> Zaak:

case.zaaktype_config = zaaktype_config

if zaaktype_config:
if zaaktype_config and case.status:
statustype_config = ZaakTypeStatusTypeConfig.objects.get(
zaaktype_config=zaaktype_config,
statustype_url=case.status.statustype.url,
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_context_data(self, **kwargs):
self.case, user=self.request.user
)
)
questions.sort(key=lambda q: q["registered_date"], reverse=True)
# questions.sort(key=lambda q: q["registered_date"], reverse=True)

statustypen = []
catalogi_client = api_group.catalogi_client
Expand Down
23 changes: 19 additions & 4 deletions src/open_inwoner/openklant/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
from open_inwoner.utils.api import ClientError, get_json_response
from open_inwoner.utils.logentry import system_action
from open_inwoner.utils.time import instance_is_new
from open_inwoner.utils.url import uuid_from_url
from open_inwoner.utils.views import LogMixin
from openklant2.client import OpenKlant2Client
from openklant2.types.resources.digitaal_adres import DigitaalAdres
Expand Down Expand Up @@ -1340,6 +1339,8 @@ def questions_for_partij(self, partij_uuid: str) -> list[OpenKlant2Question]:
# No onderwerp object, so we treat this klantcontact as a question
question_uuids.append(klantcontact["uuid"])

question_uuids.append(klantcontact["uuid"])

question_objs: list[OpenKlant2Question] = []
for question_uuid in question_uuids:
question = klantcontact_uuid_to_klantcontact_object[question_uuid]
Expand Down Expand Up @@ -1416,7 +1417,7 @@ def _build_question_dto(
{
"identification": question_ok2.nummer,
"api_source_url": question_ok2.url,
"api_source_uuid": uuid_from_url(question_ok2.url),
"api_source_uuid": str(question_ok2.question_kcm_uuid),
"subject": question_ok2.onderwerp,
"question_text": question_ok2.question,
"answer_text": answer_text,
Expand All @@ -1441,5 +1442,19 @@ def _has_new_answer_available(
)
return answer_is_recent and not answer.is_seen

def list_questions_for_zaak(self, zaak: Zaak, user: User) -> list[Question]:
return []
def list_questions_for_zaak(
self,
zaak: Zaak,
user: User,
) -> list[Question]:
klantcontacten_for_zaak = self.client.klant_contact.list(
params={
"onderwerpobject__onderwerpobjectidentificatorObjectId": zaak.identificatie
}
)["results"]

questions = [
OpenKlant2Question.from_klantcontact_and_answer(klantcontact, None)
for klantcontact in klantcontacten_for_zaak
]
return self._build_question_dtos(questions_ok2=questions, user=user)

0 comments on commit a6d8b4a

Please sign in to comment.