Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assorted issues in the OpenKlant2 service #1525

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/open_inwoner/openklant/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ def create_question(
if len(question.rstrip()) == 0:
raise ValueError("You must provide a question")

if self.mijn_vragen_actor is None:
if self.config.mijn_vragen_actor is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We check for and set the mijn_vragen_actor in the __init__ of the service, although we didn't provide for the case when the actor is not set in the config, hence the old cold would give an AttributeError. Alternatively, you could update the class attributes with mijn_vragen_actor: str | uuid.UUID | None = None, then the old check if self.mijn_vragen_actor is None could remain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, but I suggest we keep this for now. I wanted to stay close to parity and the extra check can't hurt, but when we revamp the config we should reconsider these constraints.

raise RuntimeError(
"You must define an actor to whom the question will be assigned. "
"Initialize the service with a value for `mijn_vragen_actor`."
Expand Down Expand Up @@ -1168,7 +1168,7 @@ def create_question(
"toelichting": "Beantwoorden vraag",
"gevraagdeHandeling": "Vraag beantwoorden in aanleiding gevend klant contact",
"status": "te_verwerken",
"toegewezenAanActor": {"uuid": str(self.mijn_vragen_actor)},
"toegewezenAanActor": {"uuid": str(self.config.mijn_vragen_actor)},
}
)
logger.info("Created taak: %s", taak["uuid"])
Expand Down Expand Up @@ -1333,42 +1333,43 @@ def retrieve_question(
# should return (Question, zaak_with_api_group); the latter is left out until a
# standard for linking klantcontact + zaak is agreed upon
# https://github.com/Klantinteractie-Servicesysteem/KISS-frontend/issues/808#issuecomment-2357637675
return self._build_question_dto(question), None
return self._build_question_dto(question_ok2=question, user=user), None

def _build_question_dtos(
self,
questions_ok2: list[OpenKlant2Question],
user: User,
) -> list[Question]:
return [
self._build_question_dto(questions_ok2, user=user)
for question in questions_ok2
self._build_question_dto(question, user=user) for question in questions_ok2
]

def _build_question_dto(
self,
question_ok2: OpenKlant2Question,
user: User,
) -> Question:
answer_metadata = KlantContactMomentAnswer.objects.get_or_create(
answer_metadata, _ = KlantContactMomentAnswer.objects.get_or_create(
user=user, contactmoment_url=question_ok2.url
)
answer_text = question_ok2.answer.answer if question_ok2.answer else None

return QuestionValidator.validate_python(
{
"identification": question_ok2.nummer,
"api_source_url": question_ok2.url,
"api_source_uuid": uuid_from_url(question_ok2.url),
"subject": question_ok2.onderwerp,
"question_text": question_ok2.question,
"answer_text": question_ok2.answer.answer,
"answer_text": answer_text,
"registered_date": question_ok2.plaatsgevonden_op,
"status": "",
"status": "Beantwoord" if answer_text is not None else "Onbeantwoord",
"channel": question_ok2.kanaal,
"case_detail_url": getattr(question_ok2, "zaak_url", None),
"new_answer_available": self._has_new_answer_available(
question_ok2, answer=answer_metadata
),
"api_service": KlantenServiceType.openklant2,
"api_service": KlantenServiceType.OPENKLANT2,
}
)

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interactions:
uri: http://localhost:8338/klantinteracties/api/v1/actoren
response:
body:
string: '{"uuid":"c16bf3de-171e-494e-be59-675c357bc2ad","url":"http://localhost:8338/klantinteracties/api/v1/actoren/c16bf3de-171e-494e-be59-675c357bc2ad","naam":"Afdeling
string: '{"uuid":"fe487b6f-f4e2-4cab-829e-d24dc22339fb","url":"http://localhost:8338/klantinteracties/api/v1/actoren/fe487b6f-f4e2-4cab-829e-d24dc22339fb","naam":"Afdeling
Klantenservice","soortActor":"organisatorische_eenheid","indicatieActief":true,"actoridentificator":{"objectId":"","codeObjecttype":"","codeRegister":"","codeSoortObjectId":""},"actorIdentificatie":null}'
headers:
API-version:
Expand All @@ -23,17 +23,16 @@ interactions:
Content-Length:
- '366'
Content-Security-Policy:
- 'object-src ''none''; worker-src ''self'' blob:; font-src ''self'' fonts.gstatic.com;
script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
default-src ''self''; frame-ancestors ''none''; base-uri ''self''; style-src
''self'' ''unsafe-inline'' fonts.googleapis.com; frame-src ''self''; form-action
''self'''
- 'script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
form-action ''self''; worker-src ''self'' blob:; base-uri ''self''; frame-ancestors
''none''; object-src ''none''; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com;
default-src ''self''; frame-src ''self''; font-src ''self'' fonts.gstatic.com'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Location:
- http://localhost:8338/klantinteracties/api/v1/actoren/c16bf3de-171e-494e-be59-675c357bc2ad
- http://localhost:8338/klantinteracties/api/v1/actoren/fe487b6f-f4e2-4cab-829e-d24dc22339fb
Referrer-Policy:
- same-origin
Vary:
Expand All @@ -47,10 +46,10 @@ interactions:
message: Created
- request:
body: '{"digitaleAdressen": null, "voorkeursDigitaalAdres": null, "rekeningnummers":
null, "voorkeursRekeningnummer": null, "indicatieGeheimhouding": true, "indicatieActief":
true, "voorkeurstaal": "udm", "soortPartij": "persoon", "partijIdentificatie":
{"contactnaam": {"voorletters": "Mr.", "voornaam": "Alice", "voorvoegselAchternaam":
"Mrs.", "achternaam": "McAlice"}}}'
null, "voorkeursRekeningnummer": null, "indicatieGeheimhouding": false, "indicatieActief":
true, "voorkeurstaal": "cor", "soortPartij": "persoon", "partijIdentificatie":
{"contactnaam": {"voorletters": "Mx.", "voornaam": "Alice", "voorvoegselAchternaam":
"Mr.", "achternaam": "McAlice"}}}'
headers:
Authorization:
- Token b2eb1da9861da88743d72a3fb4344288fe2cba44
Expand All @@ -62,27 +61,26 @@ interactions:
uri: http://localhost:8338/klantinteracties/api/v1/partijen
response:
body:
string: '{"uuid":"17ff1b50-a4ac-4b10-8ad0-f3b4a09e74c5","url":"http://localhost:8338/klantinteracties/api/v1/partijen/17ff1b50-a4ac-4b10-8ad0-f3b4a09e74c5","nummer":"0000000001","interneNotitie":"","betrokkenen":[],"categorieRelaties":[],"digitaleAdressen":[],"voorkeursDigitaalAdres":null,"vertegenwoordigden":[],"rekeningnummers":[],"voorkeursRekeningnummer":null,"partijIdentificatoren":[],"soortPartij":"persoon","indicatieGeheimhouding":true,"voorkeurstaal":"udm","indicatieActief":true,"bezoekadres":{"nummeraanduidingId":"","adresregel1":"","adresregel2":"","adresregel3":"","land":""},"correspondentieadres":{"nummeraanduidingId":"","adresregel1":"","adresregel2":"","adresregel3":"","land":""},"partijIdentificatie":{"contactnaam":{"voorletters":"Mr.","voornaam":"Alice","voorvoegselAchternaam":"Mrs.","achternaam":"McAlice"},"volledigeNaam":"Alice
Mrs. McAlice"}}'
string: '{"uuid":"6b519828-bfdd-490b-9f1c-f1a427518387","url":"http://localhost:8338/klantinteracties/api/v1/partijen/6b519828-bfdd-490b-9f1c-f1a427518387","nummer":"0000000001","interneNotitie":"","betrokkenen":[],"categorieRelaties":[],"digitaleAdressen":[],"voorkeursDigitaalAdres":null,"vertegenwoordigden":[],"rekeningnummers":[],"voorkeursRekeningnummer":null,"partijIdentificatoren":[],"soortPartij":"persoon","indicatieGeheimhouding":false,"voorkeurstaal":"cor","indicatieActief":true,"bezoekadres":{"nummeraanduidingId":"","adresregel1":"","adresregel2":"","adresregel3":"","land":""},"correspondentieadres":{"nummeraanduidingId":"","adresregel1":"","adresregel2":"","adresregel3":"","land":""},"partijIdentificatie":{"contactnaam":{"voorletters":"Mx.","voornaam":"Alice","voorvoegselAchternaam":"Mr.","achternaam":"McAlice"},"volledigeNaam":"Alice
Mr. McAlice"}}'
headers:
API-version:
- 0.0.3
Allow:
- GET, POST, HEAD, OPTIONS
Content-Length:
- '864'
- '863'
Content-Security-Policy:
- 'object-src ''none''; worker-src ''self'' blob:; font-src ''self'' fonts.gstatic.com;
script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
default-src ''self''; frame-ancestors ''none''; base-uri ''self''; style-src
''self'' ''unsafe-inline'' fonts.googleapis.com; frame-src ''self''; form-action
''self'''
- 'script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
form-action ''self''; worker-src ''self'' blob:; base-uri ''self''; frame-ancestors
''none''; object-src ''none''; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com;
default-src ''self''; frame-src ''self''; font-src ''self'' fonts.gstatic.com'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Location:
- http://localhost:8338/klantinteracties/api/v1/partijen/17ff1b50-a4ac-4b10-8ad0-f3b4a09e74c5
- http://localhost:8338/klantinteracties/api/v1/partijen/6b519828-bfdd-490b-9f1c-f1a427518387
Referrer-Policy:
- same-origin
Vary:
Expand All @@ -96,42 +94,41 @@ interactions:
message: Created
- request:
body: '{"digitaleAdressen": null, "voorkeursDigitaalAdres": null, "rekeningnummers":
null, "voorkeursRekeningnummer": null, "indicatieGeheimhouding": true, "indicatieActief":
false, "voorkeurstaal": "mwr", "soortPartij": "persoon", "partijIdentificatie":
{"contactnaam": {"voorletters": "Mrs.", "voornaam": "Bob", "voorvoegselAchternaam":
null, "voorkeursRekeningnummer": null, "indicatieGeheimhouding": false, "indicatieActief":
true, "voorkeurstaal": "crh", "soortPartij": "persoon", "partijIdentificatie":
{"contactnaam": {"voorletters": "Mx.", "voornaam": "Bob", "voorvoegselAchternaam":
"Mr.", "achternaam": "McBob"}}}'
headers:
Authorization:
- Token b2eb1da9861da88743d72a3fb4344288fe2cba44
Content-Length:
- '363'
- '362'
Content-Type:
- application/json
method: POST
uri: http://localhost:8338/klantinteracties/api/v1/partijen
response:
body:
string: '{"uuid":"2deecc75-8075-4986-be2b-d8b076a0a3fe","url":"http://localhost:8338/klantinteracties/api/v1/partijen/2deecc75-8075-4986-be2b-d8b076a0a3fe","nummer":"0000000002","interneNotitie":"","betrokkenen":[],"categorieRelaties":[],"digitaleAdressen":[],"voorkeursDigitaalAdres":null,"vertegenwoordigden":[],"rekeningnummers":[],"voorkeursRekeningnummer":null,"partijIdentificatoren":[],"soortPartij":"persoon","indicatieGeheimhouding":true,"voorkeurstaal":"mwr","indicatieActief":false,"bezoekadres":{"nummeraanduidingId":"","adresregel1":"","adresregel2":"","adresregel3":"","land":""},"correspondentieadres":{"nummeraanduidingId":"","adresregel1":"","adresregel2":"","adresregel3":"","land":""},"partijIdentificatie":{"contactnaam":{"voorletters":"Mrs.","voornaam":"Bob","voorvoegselAchternaam":"Mr.","achternaam":"McBob"},"volledigeNaam":"Bob
string: '{"uuid":"71a01dce-d67b-4737-9c90-82aa04021bbd","url":"http://localhost:8338/klantinteracties/api/v1/partijen/71a01dce-d67b-4737-9c90-82aa04021bbd","nummer":"0000000002","interneNotitie":"","betrokkenen":[],"categorieRelaties":[],"digitaleAdressen":[],"voorkeursDigitaalAdres":null,"vertegenwoordigden":[],"rekeningnummers":[],"voorkeursRekeningnummer":null,"partijIdentificatoren":[],"soortPartij":"persoon","indicatieGeheimhouding":false,"voorkeurstaal":"crh","indicatieActief":true,"bezoekadres":{"nummeraanduidingId":"","adresregel1":"","adresregel2":"","adresregel3":"","land":""},"correspondentieadres":{"nummeraanduidingId":"","adresregel1":"","adresregel2":"","adresregel3":"","land":""},"partijIdentificatie":{"contactnaam":{"voorletters":"Mx.","voornaam":"Bob","voorvoegselAchternaam":"Mr.","achternaam":"McBob"},"volledigeNaam":"Bob
Mr. McBob"}}'
headers:
API-version:
- 0.0.3
Allow:
- GET, POST, HEAD, OPTIONS
Content-Length:
- '856'
- '855'
Content-Security-Policy:
- 'object-src ''none''; worker-src ''self'' blob:; font-src ''self'' fonts.gstatic.com;
script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
default-src ''self''; frame-ancestors ''none''; base-uri ''self''; style-src
''self'' ''unsafe-inline'' fonts.googleapis.com; frame-src ''self''; form-action
''self'''
- 'script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
form-action ''self''; worker-src ''self'' blob:; base-uri ''self''; frame-ancestors
''none''; object-src ''none''; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com;
default-src ''self''; frame-src ''self''; font-src ''self'' fonts.gstatic.com'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Location:
- http://localhost:8338/klantinteracties/api/v1/partijen/2deecc75-8075-4986-be2b-d8b076a0a3fe
- http://localhost:8338/klantinteracties/api/v1/partijen/71a01dce-d67b-4737-9c90-82aa04021bbd
Referrer-Policy:
- same-origin
Vary:
Expand All @@ -157,7 +154,7 @@ interactions:
uri: http://localhost:8338/klantinteracties/api/v1/actoren
response:
body:
string: '{"uuid":"cf1fba57-663d-40fe-b317-0688bc4a43bf","url":"http://localhost:8338/klantinteracties/api/v1/actoren/cf1fba57-663d-40fe-b317-0688bc4a43bf","naam":"Afdeling
string: '{"uuid":"9019282d-1e7c-447a-a37e-f9c7024f952c","url":"http://localhost:8338/klantinteracties/api/v1/actoren/9019282d-1e7c-447a-a37e-f9c7024f952c","naam":"Afdeling
klantenservice","soortActor":"organisatorische_eenheid","indicatieActief":true,"actoridentificator":{"objectId":"","codeObjecttype":"","codeRegister":"","codeSoortObjectId":""},"actorIdentificatie":null}'
headers:
API-version:
Expand All @@ -167,17 +164,16 @@ interactions:
Content-Length:
- '366'
Content-Security-Policy:
- 'object-src ''none''; worker-src ''self'' blob:; font-src ''self'' fonts.gstatic.com;
script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
default-src ''self''; frame-ancestors ''none''; base-uri ''self''; style-src
''self'' ''unsafe-inline'' fonts.googleapis.com; frame-src ''self''; form-action
''self'''
- 'script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
form-action ''self''; worker-src ''self'' blob:; base-uri ''self''; frame-ancestors
''none''; object-src ''none''; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com;
default-src ''self''; frame-src ''self''; font-src ''self'' fonts.gstatic.com'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Location:
- http://localhost:8338/klantinteracties/api/v1/actoren/cf1fba57-663d-40fe-b317-0688bc4a43bf
- http://localhost:8338/klantinteracties/api/v1/actoren/9019282d-1e7c-447a-a37e-f9c7024f952c
Referrer-Policy:
- same-origin
Vary:
Expand Down
Loading
Loading