-
Notifications
You must be signed in to change notification settings - Fork 3
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
✨ [#147] Convenience endpoint for Klantcontact/Betrokkene/Onderwerpobject #260
Conversation
4709654
to
d03fd1b
Compare
@@ -48,6 +49,11 @@ | |||
router.register("betrokkenen", BetrokkeneViewSet) | |||
router.register("onderwerpobjecten", OnderwerpobjectViewSet) | |||
router.register("bijlagen", BijlageViewSet) | |||
router.register( | |||
"klantcontact-convenience", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how else I could name it without being way too long 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good name 👍
I had several questions, mostly related to the datamodel itself, because I haven't looked at it before:
|
dc1e6ba
to
61d3f1f
Compare
@stevenbal nog even bespreken? Voordat je merged :) |
@joeribekker ja dat lijkt me goed, was ook nog niet van plan het te mergen :p |
@stevenbal please contact me on Slack to discuss when you pick this up again. |
@bart-maykin I discussed with Joeri and I made both |
.github/workflows/ci.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to rebase onto master
whenever #268 gets merged
src/openklant/components/klantinteracties/api/serializers/klantcontacten.py
Show resolved
Hide resolved
src/openklant/components/klantinteracties/api/serializers/klantcontacten.py
Outdated
Show resolved
Hide resolved
Create the objects and use the original serializers to ensure all the correct | ||
fields show up in the response | ||
""" | ||
klantcontact_data = validated_data["klantcontact"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens here when no klantcontact
was given in the request data? Will it raise a KeyError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is required on the serializer, you will get a validation error:
{
"type": "http://localhost:8000/ref/fouten/ValidationError/",
"code": "invalid",
"title": "Invalid input.",
"status": 400,
"detail": "",
"instance": "urn:uuid:5f54a6d6-5327-4ad5-a831-27b7be3c1035",
"invalidParams": [
{
"name": "klantcontact",
"code": "required",
"reason": "Dit veld is vereist."
}
]
}
src/openklant/components/klantinteracties/api/viewsets/klantcontacten.py
Outdated
Show resolved
Hide resolved
@@ -48,6 +49,11 @@ | |||
router.register("betrokkenen", BetrokkeneViewSet) | |||
router.register("onderwerpobjecten", OnderwerpobjectViewSet) | |||
router.register("bijlagen", BijlageViewSet) | |||
router.register( | |||
"klantcontact-convenience", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good name 👍
src/openklant/components/klantinteracties/api/tests/test_klantcontacten.py
Outdated
Show resolved
Hide resolved
betrokkene = None | ||
if betrokkene_data := validated_data.pop("betrokkene", None): | ||
betrokkene_data["had_klantcontact"] = {"uuid": str(klantcontact.uuid)} | ||
# TODO for some reason `was_partij` is converted to `partij` by the serializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is caused by the source
option given to the was_partij
field
open-klant/src/openklant/components/klantinteracties/api/serializers/klantcontacten.py
Line 139 in 2963f4c
source="partij", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I see, I don't think there's a way around this, since it always gets deserialized to partij
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I never knew this was how the source
option behaved 😮. The comment can be removed though right?
8c883f0
to
424d9fb
Compare
424d9fb
to
ba76269
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice this saved the tests some code 👍
""" | ||
|
||
serializer_class = KlantContactConvenienceSerializer | ||
authentication_classes = (TokenAuthentication,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In think this should be the default for the API but is not part of the ticket 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume since the other endpoints use tokenauth, this one should too :p
betrokkene = None | ||
if betrokkene_data := validated_data.pop("betrokkene", None): | ||
betrokkene_data["had_klantcontact"] = {"uuid": str(klantcontact.uuid)} | ||
# TODO for some reason `was_partij` is converted to `partij` by the serializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I never knew this was how the source
option behaved 😮. The comment can be removed though right?
previously this used the Klantcontact view, causing incorrect URLs to appear in the detail response for the Onderwerpobject endpoint
…ject to allow creation of these three resources in a single API call
… endpoint because it should be possible to create e.g.: - a KlantContact with a Betrokkene but no OnderwerpObject - a KlantContact with an OnderwerpObject but no Betrokkene
cbd54f4
to
0e2d540
Compare
0e2d540
to
88f23a4
Compare
Fixes #147
Changes