|
46 | 46 | PartijIdentificatorTypesValidator,
|
47 | 47 | PartijIdentificatorUniquenessValidator,
|
48 | 48 | )
|
| 49 | +from openklant.utils.decorators import handle_db_exceptions |
49 | 50 | from openklant.utils.serializers import get_field_instance_by_uuid, get_field_value
|
50 | 51 |
|
51 | 52 |
|
@@ -371,10 +372,7 @@ class Meta:
|
371 | 372 | "code_soort_object_id": {"required": True},
|
372 | 373 | "object_id": {"required": True},
|
373 | 374 | }
|
374 |
| - |
375 |
| - def validate(self, attrs): |
376 |
| - PartijIdentificatorTypesValidator(partij_identificator=attrs)() |
377 |
| - return super().validate(attrs) |
| 375 | + validators = [] |
378 | 376 |
|
379 | 377 |
|
380 | 378 | class PartijIdentificatorSerializer(
|
@@ -420,27 +418,38 @@ class Meta:
|
420 | 418 | }
|
421 | 419 |
|
422 | 420 | def validate(self, attrs):
|
423 |
| - instance = getattr(self, "instance", None) |
424 | 421 | partij_identificator = get_field_value(self, attrs, "partij_identificator")
|
425 |
| - |
426 | 422 | sub_identificator_van = get_field_instance_by_uuid(
|
427 | 423 | self, attrs, "sub_identificator_van", PartijIdentificator
|
428 | 424 | )
|
429 | 425 | partij = get_field_instance_by_uuid(self, attrs, "partij", Partij)
|
430 | 426 |
|
| 427 | + PartijIdentificatorTypesValidator()( |
| 428 | + code_objecttype=partij_identificator["code_objecttype"], |
| 429 | + code_soort_object_id=partij_identificator["code_soort_object_id"], |
| 430 | + object_id=partij_identificator["object_id"], |
| 431 | + code_register=partij_identificator["code_register"], |
| 432 | + ) |
431 | 433 | PartijIdentificatorUniquenessValidator(
|
432 |
| - instance=instance, |
433 |
| - partij_identificator=partij_identificator, |
| 434 | + code_soort_object_id=partij_identificator["code_soort_object_id"], |
434 | 435 | sub_identificator_van=sub_identificator_van,
|
435 |
| - partij=partij, |
436 | 436 | )()
|
437 | 437 |
|
438 |
| - attrs["sub_identificator_van"] = get_field_instance_by_uuid( |
439 |
| - self, attrs, "sub_identificator_van", PartijIdentificator |
440 |
| - ) |
441 |
| - attrs["partij"] = get_field_instance_by_uuid(self, attrs, "partij", Partij) |
| 438 | + attrs["sub_identificator_van"] = sub_identificator_van |
| 439 | + attrs["partij"] = partij |
| 440 | + |
442 | 441 | return super().validate(attrs)
|
443 | 442 |
|
| 443 | + @handle_db_exceptions |
| 444 | + @transaction.atomic |
| 445 | + def update(self, instance, validated_data): |
| 446 | + return super().update(instance, validated_data) |
| 447 | + |
| 448 | + @handle_db_exceptions |
| 449 | + @transaction.atomic |
| 450 | + def create(self, validated_data): |
| 451 | + return super().create(validated_data) |
| 452 | + |
444 | 453 |
|
445 | 454 | class PartijSerializer(NestedGegevensGroepMixin, PolymorphicSerializer):
|
446 | 455 | from openklant.components.klantinteracties.api.serializers.rekeningnummers import (
|
|
0 commit comments