Skip to content
Snippets Groups Projects

GREG-17: Duplicate check

Merged Tore.Brede requested to merge GREG-17_duplicate_check into master
All threads resolved!
3 files
+ 55
0
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -37,3 +37,18 @@ class PersonIdentitySerializer(serializers.ModelSerializer):
@@ -37,3 +37,18 @@ class PersonIdentitySerializer(serializers.ModelSerializer):
class Meta:
class Meta:
model = PersonIdentity
model = PersonIdentity
fields = "__all__"
fields = "__all__"
 
 
def is_duplicate(self, identity_type: str, value: str) -> bool:
 
# Guests may be verified using another unrecognised identification method,
 
# which the sponsor is required to elaborate in the value column.
 
# In this case we cannot assume the union of the identity type and
 
# the value to be unique across all records.
 
if identity_type == PersonIdentity.IdentityType.OTHER:
 
return False
 
 
# If the type is a specific ID type, then duplicates are not expected
 
return (
 
PersonIdentity.objects.filter(type__like=identity_type)
 
.filter(value__like=value)
 
.exists()
 
)
Loading