From 7a0605bc057d3ea210ba685e9fd814f7f70eb14c Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Fri, 6 Dec 2024 09:51:36 +0100 Subject: [PATCH] feat(models): add alternative_names_new field using the JSONEditorField --- ...4_person_alternative_names_new_and_more.py | 23 ++++++++++++++++++ apis_ontology/models.py | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 apis_ontology/migrations/0044_person_alternative_names_new_and_more.py diff --git a/apis_ontology/migrations/0044_person_alternative_names_new_and_more.py b/apis_ontology/migrations/0044_person_alternative_names_new_and_more.py new file mode 100644 index 0000000..2dbc1cd --- /dev/null +++ b/apis_ontology/migrations/0044_person_alternative_names_new_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.1.4 on 2024-12-06 08:35 + +import django_json_editor_field.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("apis_ontology", "0043_fandstattin_versionfandstattin"), + ] + + operations = [ + migrations.AddField( + model_name="person", + name="alternative_names_new", + field=django_json_editor_field.fields.JSONEditorField(null=True), + ), + migrations.AddField( + model_name="versionperson", + name="alternative_names_new", + field=django_json_editor_field.fields.JSONEditorField(null=True), + ), + ] diff --git a/apis_ontology/models.py b/apis_ontology/models.py index f132932..b7e55ca 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -12,6 +12,7 @@ from apis_core.apis_entities.abc import E53_Place from apis_core.history.models import VersionMixin from apis_core.utils.fields import NewlineSeparatedListField +from django_json_editor_field.fields import JSONEditorField from auditlog.registry import auditlog @@ -174,6 +175,29 @@ class Person( alternative_names = NewlineSeparatedListField( blank=True, verbose_name=_("Alternative Names") ) + schema = { + "title": "Alternative Names", + "type": "array", + "format": "table", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + }, + "start": { + "type": "string", + "format": "date", + }, + "end": { + "type": "string", + "format": "date", + }, + }, + }, + } + + alternative_names_new = JSONEditorField(schema=schema, null=True) # texts # "ÖBL Haupttext"