@@ -427,24 +427,24 @@ def validate(self, attrs):
427
427
self , attrs , "sub_identificator_van" , PartijIdentificator
428
428
)
429
429
partij = get_field_instance_by_uuid (self , attrs , "partij" , Partij )
430
-
431
- PartijIdentificatorTypesValidator ()(
432
- code_objecttype = partij_identificator ["code_objecttype" ],
433
- code_soort_object_id = partij_identificator ["code_soort_object_id" ],
434
- object_id = partij_identificator ["object_id" ],
435
- code_register = partij_identificator ["code_register" ],
436
- )
437
- PartijIdentificatorUniquenessValidator (
438
- code_soort_object_id = partij_identificator ["code_soort_object_id" ],
439
- sub_identificator_van = sub_identificator_van ,
440
- )()
430
+ if partij_identificator :
431
+ PartijIdentificatorTypesValidator ()(
432
+ code_objecttype = partij_identificator ["code_objecttype" ],
433
+ code_soort_object_id = partij_identificator ["code_soort_object_id" ],
434
+ object_id = partij_identificator ["object_id" ],
435
+ code_register = partij_identificator ["code_register" ],
436
+ )
437
+ PartijIdentificatorUniquenessValidator (
438
+ code_soort_object_id = partij_identificator ["code_soort_object_id" ],
439
+ sub_identificator_van = sub_identificator_van ,
440
+ )()
441
441
442
442
attrs ["sub_identificator_van" ] = sub_identificator_van
443
443
attrs ["partij" ] = partij
444
444
445
445
return super ().validate (attrs )
446
446
447
- def assert_partij (self , partij ):
447
+ def validate_partij (self , partij ):
448
448
if not partij :
449
449
raise serializers .ValidationError (
450
450
{"identificeerdePartij" : _ ("Dit veld is vereist." )},
@@ -454,13 +454,13 @@ def assert_partij(self, partij):
454
454
@handle_db_exceptions
455
455
@transaction .atomic
456
456
def update (self , instance , validated_data ):
457
- self .assert_partij (validated_data ["partij" ])
457
+ self .validate_partij (validated_data ["partij" ])
458
458
return super ().update (instance , validated_data )
459
459
460
460
@handle_db_exceptions
461
461
@transaction .atomic
462
462
def create (self , validated_data ):
463
- self .assert_partij (validated_data ["partij" ])
463
+ self .validate_partij (validated_data ["partij" ])
464
464
return super ().create (validated_data )
465
465
466
466
@@ -634,6 +634,11 @@ def validate_partij_identificatoren(self, attrs):
634
634
return attrs
635
635
636
636
def update_or_create_partij_identificator (self , partij_identificator ):
637
+ sub_identificator_van = partij_identificator ["sub_identificator_van" ]
638
+ if isinstance (sub_identificator_van , PartijIdentificator ):
639
+ partij_identificator ["sub_identificator_van" ] = {
640
+ "uuid" : sub_identificator_van .uuid
641
+ }
637
642
partij_identificator_serializer = PartijIdentificatorSerializer (
638
643
data = partij_identificator
639
644
)
0 commit comments