Skip to content
Snippets Groups Projects
Commit 21341895 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-140: Remove other identity type

parent 4f96eba8
No related branches found
No related tags found
1 merge request!195GREG-140: Remove other identity type
Pipeline #103098 passed
......@@ -10,14 +10,6 @@ class IdentitySerializer(serializers.ModelSerializer):
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 == Identity.IdentityType.OTHER:
return False
# If the type is a specific ID type, then duplicates are not expected
return Identity.objects.filter(type=identity_type).filter(value=value).exists()
def validate(self, attrs):
......
# Generated by Django 3.2.9 on 2021-12-08 07:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('greg', '0017_consent_choices'),
]
operations = [
migrations.AlterField(
model_name='identity',
name='type',
field=models.CharField(choices=[('feide_id', 'Feide Id'), ('feide_email', 'Feide Email'), ('passport_number', 'Passport Number'), ('norwegian_national_id_number', 'Norwegian National Id Number'), ('private_email', 'Private Email'), ('private_mobile', 'Private Mobile Number')], max_length=64),
),
]
......@@ -139,12 +139,12 @@ class Person(BaseModel):
Due to the diversity of guests at a university institution,
there are many ways for guests to identify themselves.
These include Feide ID, passport number, driver's license,
national ID card, or another manual (human) verification.
These include Feide ID, passport number, driver's license
and national ID card.
Some of these methods are implicitly trusted (Feide ID) because
the guest is likely a visitor from another academic institution
who has already been pre-verified. Others are manul, such
who has already been pre-verified. Others are manual, such
as the sponsor vouching for having checked the guest's
personal details against his or her passport.
......@@ -274,8 +274,6 @@ class Identity(BaseModel):
NORWEGIAN_NATIONAL_ID_NUMBER = "norwegian_national_id_number"
PRIVATE_EMAIL = "private_email"
PRIVATE_MOBILE_NUMBER = "private_mobile"
# Sponsor writes what is used in the value column
OTHER = "other"
class Verified(models.TextChoices):
AUTOMATIC = "automatic"
......
......@@ -243,22 +243,24 @@ def test_identity_add_duplicate_fails(client, person_foo, person_bar):
@pytest.mark.django_db
def test_identity_add_valid_duplicate(client, person_foo, person_bar):
def test_add_invalid_type(client, person):
data = {
"type": Identity.IdentityType.OTHER,
"type": "OTHER",
"source": "Test source",
"value": "12345",
}
client.post(
reverse("v1:person_identity-list", kwargs={"person_id": person_bar.id}),
data=data,
)
client.post(
reverse("v1:person_identity-list", kwargs={"person_id": person_foo.id}),
assert len(person.identities.all()) == 0
response = client.post(
reverse("v1:person_identity-list", kwargs={"person_id": person.id}),
data=data,
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
person.refresh_from_db()
assert len(person.identities.all()) == 0
@pytest.mark.django_db
def test_identity_delete(client, person):
......
......@@ -143,7 +143,6 @@ def test_is_registered_completed_in_future(person_registered_future):
(Identity.IdentityType.PRIVATE_EMAIL, False),
(Identity.IdentityType.PRIVATE_MOBILE_NUMBER, False),
(Identity.IdentityType.FEIDE_ID, False),
(Identity.IdentityType.OTHER, False),
),
)
def test_is_verified(identity_type, is_verified, person):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment