From 59bed02086c002c3b17b80bea5424d7170b3b26c Mon Sep 17 00:00:00 2001
From: Jonas Braathen <jonas.braathen@usit.uio.no>
Date: Thu, 2 Feb 2023 11:24:50 +0100
Subject: [PATCH] Add an identity type for generic national ID card numbers

---
 ...entity_type_add_national_id_card_number.py | 34 +++++++++++++++++++
 greg/models.py                                | 13 +++++--
 2 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100644 greg/migrations/0029_alter_identity_type_add_national_id_card_number.py

diff --git a/greg/migrations/0029_alter_identity_type_add_national_id_card_number.py b/greg/migrations/0029_alter_identity_type_add_national_id_card_number.py
new file mode 100644
index 00000000..504a3dcf
--- /dev/null
+++ b/greg/migrations/0029_alter_identity_type_add_national_id_card_number.py
@@ -0,0 +1,34 @@
+# Generated by Django 4.1.4 on 2023-02-02 10:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("greg", "0028_person_meta_alter_invitation_role_and_more"),
+    ]
+
+    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"),
+                    (
+                        "norwegian_national_id_card_number",
+                        "Norwegian National Id Card Number",
+                    ),
+                    ("national_id_card_number", "National Id Card Number"),
+                    ("private_email", "Private Email"),
+                    ("private_mobile", "Private Mobile Number"),
+                    ("migration_id", "Migration Id"),
+                ],
+                max_length=64,
+            ),
+        ),
+    ]
diff --git a/greg/models.py b/greg/models.py
index 8b82a755..5b15a172 100644
--- a/greg/models.py
+++ b/greg/models.py
@@ -284,16 +284,25 @@ class Identity(BaseModel):
     """
 
     class IdentityType(models.TextChoices):
+        # Feide ID, i.e. eduPersonPrincipalName
         FEIDE_ID = "feide_id"
         FEIDE_EMAIL = "feide_email"
+        # Passport number
+        # Format: # Format: {ALPHA-2-COUNTRY-CODE}-{DOCUMENT-NUMBER}
         PASSPORT_NUMBER = "passport_number"
-        # Norwegian national ID - "fødselsnummer" or D-number
+        # Norwegian national ID - "fødselsnummer" or D-number (or SO-number)
+        # Format: 11 digits, with leading zero if applicable
         NORWEGIAN_NATIONAL_ID_NUMBER = "norwegian_national_id_number"
         # Norwegian national ID card document number
         NORWEGIAN_NATIONAL_ID_CARD_NUMBER = "norwegian_national_id_card_number"
+        # Catch-all for saving generic national ID card numbers
+        # Format: {ALPHA-2-COUNTRY-CODE}-{DOCUMENT-NUMBER}
+        NATIONAL_ID_CARD_NUMBER = "national_id_card_number"
         PRIVATE_EMAIL = "private_email"
+        # Mobile phone number
+        # Format: E.164
         PRIVATE_MOBILE_NUMBER = "private_mobile"
-        # Used to identify the id of this person in some other system
+        # Used to identify the ID of this person in some other system
         MIGRATION_ID = "migration_id"
 
     class Verified(models.TextChoices):
-- 
GitLab