From 2df178f4e1a7d8e0c3a92533aa7a10bb51f677ab Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Sun, 10 May 2026 09:21:36 +0200 Subject: [PATCH] # API model extension * adds model ExternalIdentifier to support linking between external ids and internal ids --- api/migrations/0004_externalidentifier.py | 23 ++++++++++++++++ api/models/__init__.py | 3 ++- api/models/external_identifier.py | 33 +++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 api/migrations/0004_externalidentifier.py create mode 100644 api/models/external_identifier.py diff --git a/api/migrations/0004_externalidentifier.py b/api/migrations/0004_externalidentifier.py new file mode 100644 index 00000000..9de36dde --- /dev/null +++ b/api/migrations/0004_externalidentifier.py @@ -0,0 +1,23 @@ +# Generated by Django 6.0.5 on 2026-05-10 07:18 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0003_oauthtoken'), + ('user', '0010_user_sso_identifier'), + ] + + operations = [ + migrations.CreateModel( + name='ExternalIdentifier', + fields=[ + ('external_id', models.CharField(db_comment='Identifier from a source system', max_length=255, primary_key=True, serialize=False)), + ('internal_id', models.UUIDField(db_comment='Identifier in konova')), + ('created', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='user.useractionlogentry')), + ], + ), + ] diff --git a/api/models/__init__.py b/api/models/__init__.py index d43f0c4e..ca25c99c 100644 --- a/api/models/__init__.py +++ b/api/models/__init__.py @@ -5,4 +5,5 @@ Contact: michel.peltriaux@sgdnord.rlp.de Created on: 21.01.22 """ -from .token import * \ No newline at end of file +from .token import * +from .external_identifier import * \ No newline at end of file diff --git a/api/models/external_identifier.py b/api/models/external_identifier.py new file mode 100644 index 00000000..597197f7 --- /dev/null +++ b/api/models/external_identifier.py @@ -0,0 +1,33 @@ +""" +Author: Michel Peltriaux +Created on: 10.05.26 + +""" +from django.db import models + + +class ExternalIdentifier(models.Model): + """ Holds a lookup to match a given external identifier against the internal identifier in konova. + + Relevant in cases of API transmitted entries, which are updates using external identifiers instead of + the internal ones directly. + + """ + external_id = models.CharField( + max_length=255, + primary_key=True, + db_comment="Identifier from a source system" + ) + internal_id = models.UUIDField( + db_comment="Identifier in konova" + ) + created = models.ForeignKey( + "user.UserActionLogEntry", + on_delete=models.SET_NULL, + null=True, + blank=True, + related_name='+' + ) + + def __str__(self): + return f"{self.external_id} -> {self.internal_id}" \ No newline at end of file