diff --git a/greg/api/serializers/person.py b/greg/api/serializers/person.py index ad9c58a9843accb1e76fa002a9f91d24624a595f..dad2f1b5b0bf2181cb96a78d1d8c96ff56e1a887 100644 --- a/greg/api/serializers/person.py +++ b/greg/api/serializers/person.py @@ -39,17 +39,19 @@ class PersonIdentitySerializer(serializers.ModelSerializer): fields = "__all__" def is_duplicate(self, identity_type: str, value: str) -> bool: - # If the type is other then it is allowed that two entries are the same, since - # the text may be some generic text added by the sponsor + # 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 ( - len( - PersonIdentity.objects.filter(type__like=identity_type).filter( - value__like=value + len( + PersonIdentity.objects.filter(type__like=identity_type).filter( + value__like=value + ) ) - ) - > 0 + > 0 )