Skip to content

Commit

Permalink
feat(models): add alternative_names_new field using the JSONEditorField
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Dec 6, 2024
1 parent e410188 commit 7a0605b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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),
),
]
24 changes: 24 additions & 0 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 7a0605b

Please sign in to comment.