Skip to content

Commit 235ec5a

Browse files
authored
Merge pull request #1525 from maykinmedia/swr/demo-2024-12-10-fixes
Fix assorted issues in the OpenKlant2 service
2 parents 4ddcd7f + d948da3 commit 235ec5a

12 files changed

+855
-792
lines changed

src/open_inwoner/openklant/services.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ def create_question(
11331133
if len(question.rstrip()) == 0:
11341134
raise ValueError("You must provide a question")
11351135

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

13381338
def _build_question_dtos(
13391339
self,
13401340
questions_ok2: list[OpenKlant2Question],
13411341
user: User,
13421342
) -> list[Question]:
13431343
return [
1344-
self._build_question_dto(questions_ok2, user=user)
1345-
for question in questions_ok2
1344+
self._build_question_dto(question, user=user) for question in questions_ok2
13461345
]
13471346

13481347
def _build_question_dto(
13491348
self,
13501349
question_ok2: OpenKlant2Question,
13511350
user: User,
13521351
) -> Question:
1353-
answer_metadata = KlantContactMomentAnswer.objects.get_or_create(
1352+
answer_metadata, _ = KlantContactMomentAnswer.objects.get_or_create(
13541353
user=user, contactmoment_url=question_ok2.url
13551354
)
1355+
answer_text = question_ok2.answer.answer if question_ok2.answer else None
1356+
13561357
return QuestionValidator.validate_python(
13571358
{
13581359
"identification": question_ok2.nummer,
13591360
"api_source_url": question_ok2.url,
13601361
"api_source_uuid": uuid_from_url(question_ok2.url),
13611362
"subject": question_ok2.onderwerp,
13621363
"question_text": question_ok2.question,
1363-
"answer_text": question_ok2.answer.answer,
1364+
"answer_text": answer_text,
13641365
"registered_date": question_ok2.plaatsgevonden_op,
1365-
"status": "",
1366+
"status": "Beantwoord" if answer_text is not None else "Onbeantwoord",
13661367
"channel": question_ok2.kanaal,
13671368
"case_detail_url": getattr(question_ok2, "zaak_url", None),
13681369
"new_answer_available": self._has_new_answer_available(
13691370
question_ok2, answer=answer_metadata
13701371
),
1371-
"api_service": KlantenServiceType.openklant2,
1372+
"api_service": KlantenServiceType.OPENKLANT2,
13721373
}
13731374
)
13741375

src/open_inwoner/openklant/tests/cassettes/Openklant2ServiceTest.test_cannot_use_existing_user_email_when_updating_user_from_partij.yaml

+38-38
Large diffs are not rendered by default.

src/open_inwoner/openklant/tests/cassettes/Openklant2ServiceTest.test_update_partij_from_user.yaml

+62-62
Large diffs are not rendered by default.

src/open_inwoner/openklant/tests/cassettes/Openklant2ServiceTest.test_update_user_from_partij.yaml

+55-55
Large diffs are not rendered by default.

src/open_inwoner/openklant/tests/cassettes/PartijGetOrCreateTestCase.test_get_or_create_organisatie_with_vestiging.yaml

+63-75
Large diffs are not rendered by default.

src/open_inwoner/openklant/tests/cassettes/PartijGetOrCreateTestCase.test_get_or_create_organisatie_without_vestiging.yaml

+56-67
Large diffs are not rendered by default.

src/open_inwoner/openklant/tests/cassettes/PartijGetOrCreateTestCase.test_get_or_create_persoon.yaml

+56-67
Large diffs are not rendered by default.

src/open_inwoner/openklant/tests/cassettes/QuestionAnswerTestCase.test_create_question.yaml

+73-83
Large diffs are not rendered by default.

src/open_inwoner/openklant/tests/cassettes/QuestionAnswerTestCase.test_create_question_raises_on_missing_question.yaml

+35-39
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interactions:
1313
uri: http://localhost:8338/klantinteracties/api/v1/actoren
1414
response:
1515
body:
16-
string: '{"uuid":"c16bf3de-171e-494e-be59-675c357bc2ad","url":"http://localhost:8338/klantinteracties/api/v1/actoren/c16bf3de-171e-494e-be59-675c357bc2ad","naam":"Afdeling
16+
string: '{"uuid":"fe487b6f-f4e2-4cab-829e-d24dc22339fb","url":"http://localhost:8338/klantinteracties/api/v1/actoren/fe487b6f-f4e2-4cab-829e-d24dc22339fb","naam":"Afdeling
1717
Klantenservice","soortActor":"organisatorische_eenheid","indicatieActief":true,"actoridentificator":{"objectId":"","codeObjecttype":"","codeRegister":"","codeSoortObjectId":""},"actorIdentificatie":null}'
1818
headers:
1919
API-version:
@@ -23,17 +23,16 @@ interactions:
2323
Content-Length:
2424
- '366'
2525
Content-Security-Policy:
26-
- 'object-src ''none''; worker-src ''self'' blob:; font-src ''self'' fonts.gstatic.com;
27-
script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
28-
default-src ''self''; frame-ancestors ''none''; base-uri ''self''; style-src
29-
''self'' ''unsafe-inline'' fonts.googleapis.com; frame-src ''self''; form-action
30-
''self'''
26+
- 'script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
27+
form-action ''self''; worker-src ''self'' blob:; base-uri ''self''; frame-ancestors
28+
''none''; object-src ''none''; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com;
29+
default-src ''self''; frame-src ''self''; font-src ''self'' fonts.gstatic.com'
3130
Content-Type:
3231
- application/json
3332
Cross-Origin-Opener-Policy:
3433
- same-origin
3534
Location:
36-
- http://localhost:8338/klantinteracties/api/v1/actoren/c16bf3de-171e-494e-be59-675c357bc2ad
35+
- http://localhost:8338/klantinteracties/api/v1/actoren/fe487b6f-f4e2-4cab-829e-d24dc22339fb
3736
Referrer-Policy:
3837
- same-origin
3938
Vary:
@@ -47,10 +46,10 @@ interactions:
4746
message: Created
4847
- request:
4948
body: '{"digitaleAdressen": null, "voorkeursDigitaalAdres": null, "rekeningnummers":
50-
null, "voorkeursRekeningnummer": null, "indicatieGeheimhouding": true, "indicatieActief":
51-
true, "voorkeurstaal": "udm", "soortPartij": "persoon", "partijIdentificatie":
52-
{"contactnaam": {"voorletters": "Mr.", "voornaam": "Alice", "voorvoegselAchternaam":
53-
"Mrs.", "achternaam": "McAlice"}}}'
49+
null, "voorkeursRekeningnummer": null, "indicatieGeheimhouding": false, "indicatieActief":
50+
true, "voorkeurstaal": "cor", "soortPartij": "persoon", "partijIdentificatie":
51+
{"contactnaam": {"voorletters": "Mx.", "voornaam": "Alice", "voorvoegselAchternaam":
52+
"Mr.", "achternaam": "McAlice"}}}'
5453
headers:
5554
Authorization:
5655
- Token b2eb1da9861da88743d72a3fb4344288fe2cba44
@@ -62,27 +61,26 @@ interactions:
6261
uri: http://localhost:8338/klantinteracties/api/v1/partijen
6362
response:
6463
body:
65-
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
66-
Mrs. McAlice"}}'
64+
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
65+
Mr. McAlice"}}'
6766
headers:
6867
API-version:
6968
- 0.0.3
7069
Allow:
7170
- GET, POST, HEAD, OPTIONS
7271
Content-Length:
73-
- '864'
72+
- '863'
7473
Content-Security-Policy:
75-
- 'object-src ''none''; worker-src ''self'' blob:; font-src ''self'' fonts.gstatic.com;
76-
script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
77-
default-src ''self''; frame-ancestors ''none''; base-uri ''self''; style-src
78-
''self'' ''unsafe-inline'' fonts.googleapis.com; frame-src ''self''; form-action
79-
''self'''
74+
- 'script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
75+
form-action ''self''; worker-src ''self'' blob:; base-uri ''self''; frame-ancestors
76+
''none''; object-src ''none''; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com;
77+
default-src ''self''; frame-src ''self''; font-src ''self'' fonts.gstatic.com'
8078
Content-Type:
8179
- application/json
8280
Cross-Origin-Opener-Policy:
8381
- same-origin
8482
Location:
85-
- http://localhost:8338/klantinteracties/api/v1/partijen/17ff1b50-a4ac-4b10-8ad0-f3b4a09e74c5
83+
- http://localhost:8338/klantinteracties/api/v1/partijen/6b519828-bfdd-490b-9f1c-f1a427518387
8684
Referrer-Policy:
8785
- same-origin
8886
Vary:
@@ -96,42 +94,41 @@ interactions:
9694
message: Created
9795
- request:
9896
body: '{"digitaleAdressen": null, "voorkeursDigitaalAdres": null, "rekeningnummers":
99-
null, "voorkeursRekeningnummer": null, "indicatieGeheimhouding": true, "indicatieActief":
100-
false, "voorkeurstaal": "mwr", "soortPartij": "persoon", "partijIdentificatie":
101-
{"contactnaam": {"voorletters": "Mrs.", "voornaam": "Bob", "voorvoegselAchternaam":
97+
null, "voorkeursRekeningnummer": null, "indicatieGeheimhouding": false, "indicatieActief":
98+
true, "voorkeurstaal": "crh", "soortPartij": "persoon", "partijIdentificatie":
99+
{"contactnaam": {"voorletters": "Mx.", "voornaam": "Bob", "voorvoegselAchternaam":
102100
"Mr.", "achternaam": "McBob"}}}'
103101
headers:
104102
Authorization:
105103
- Token b2eb1da9861da88743d72a3fb4344288fe2cba44
106104
Content-Length:
107-
- '363'
105+
- '362'
108106
Content-Type:
109107
- application/json
110108
method: POST
111109
uri: http://localhost:8338/klantinteracties/api/v1/partijen
112110
response:
113111
body:
114-
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
112+
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
115113
Mr. McBob"}}'
116114
headers:
117115
API-version:
118116
- 0.0.3
119117
Allow:
120118
- GET, POST, HEAD, OPTIONS
121119
Content-Length:
122-
- '856'
120+
- '855'
123121
Content-Security-Policy:
124-
- 'object-src ''none''; worker-src ''self'' blob:; font-src ''self'' fonts.gstatic.com;
125-
script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
126-
default-src ''self''; frame-ancestors ''none''; base-uri ''self''; style-src
127-
''self'' ''unsafe-inline'' fonts.googleapis.com; frame-src ''self''; form-action
128-
''self'''
122+
- 'script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
123+
form-action ''self''; worker-src ''self'' blob:; base-uri ''self''; frame-ancestors
124+
''none''; object-src ''none''; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com;
125+
default-src ''self''; frame-src ''self''; font-src ''self'' fonts.gstatic.com'
129126
Content-Type:
130127
- application/json
131128
Cross-Origin-Opener-Policy:
132129
- same-origin
133130
Location:
134-
- http://localhost:8338/klantinteracties/api/v1/partijen/2deecc75-8075-4986-be2b-d8b076a0a3fe
131+
- http://localhost:8338/klantinteracties/api/v1/partijen/71a01dce-d67b-4737-9c90-82aa04021bbd
135132
Referrer-Policy:
136133
- same-origin
137134
Vary:
@@ -157,7 +154,7 @@ interactions:
157154
uri: http://localhost:8338/klantinteracties/api/v1/actoren
158155
response:
159156
body:
160-
string: '{"uuid":"cf1fba57-663d-40fe-b317-0688bc4a43bf","url":"http://localhost:8338/klantinteracties/api/v1/actoren/cf1fba57-663d-40fe-b317-0688bc4a43bf","naam":"Afdeling
157+
string: '{"uuid":"9019282d-1e7c-447a-a37e-f9c7024f952c","url":"http://localhost:8338/klantinteracties/api/v1/actoren/9019282d-1e7c-447a-a37e-f9c7024f952c","naam":"Afdeling
161158
klantenservice","soortActor":"organisatorische_eenheid","indicatieActief":true,"actoridentificator":{"objectId":"","codeObjecttype":"","codeRegister":"","codeSoortObjectId":""},"actorIdentificatie":null}'
162159
headers:
163160
API-version:
@@ -167,17 +164,16 @@ interactions:
167164
Content-Length:
168165
- '366'
169166
Content-Security-Policy:
170-
- 'object-src ''none''; worker-src ''self'' blob:; font-src ''self'' fonts.gstatic.com;
171-
script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
172-
default-src ''self''; frame-ancestors ''none''; base-uri ''self''; style-src
173-
''self'' ''unsafe-inline'' fonts.googleapis.com; frame-src ''self''; form-action
174-
''self'''
167+
- 'script-src ''self'' ''unsafe-inline''; img-src ''self'' data: cdn.redoc.ly;
168+
form-action ''self''; worker-src ''self'' blob:; base-uri ''self''; frame-ancestors
169+
''none''; object-src ''none''; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com;
170+
default-src ''self''; frame-src ''self''; font-src ''self'' fonts.gstatic.com'
175171
Content-Type:
176172
- application/json
177173
Cross-Origin-Opener-Policy:
178174
- same-origin
179175
Location:
180-
- http://localhost:8338/klantinteracties/api/v1/actoren/cf1fba57-663d-40fe-b317-0688bc4a43bf
176+
- http://localhost:8338/klantinteracties/api/v1/actoren/9019282d-1e7c-447a-a37e-f9c7024f952c
181177
Referrer-Policy:
182178
- same-origin
183179
Vary:

0 commit comments

Comments
 (0)