diff --git a/apis_ontology/migrations/0045_rename_end_start_date_event_end_date_from_and_more.py b/apis_ontology/migrations/0045_rename_end_start_date_event_end_date_from_and_more.py new file mode 100644 index 0000000..d665176 --- /dev/null +++ b/apis_ontology/migrations/0045_rename_end_start_date_event_end_date_from_and_more.py @@ -0,0 +1,128 @@ +# Generated by Django 5.1.4 on 2024-12-20 07:33 + +import django_interval.fields +from django.db import migrations + +migration_list = lambda model: [ # noqa: E731 + migrations.RenameField( + model_name=model, + old_name="end_date_written", + new_name="end", + ), + migrations.RenameField( + model_name=model, + old_name="end_start_date", + new_name="end_date_from", + ), + migrations.RenameField( + model_name=model, + old_name="end_date", + new_name="end_date_sort", + ), + migrations.RenameField( + model_name=model, + old_name="end_end_date", + new_name="end_date_to", + ), + migrations.RenameField( + model_name=model, + old_name="start_date_written", + new_name="start", + ), + migrations.RenameField( + model_name=model, + old_name="start_start_date", + new_name="start_date_from", + ), + migrations.RenameField( + model_name=model, + old_name="start_date", + new_name="start_date_sort", + ), + migrations.RenameField( + model_name=model, + old_name="start_end_date", + new_name="start_date_to", + ), + migrations.AlterField( + model_name=model, + name="start", + field=django_interval.fields.FuzzyDateParserField( + blank=True, max_length=255, null=True, verbose_name="Start" + ), + ), + migrations.AlterField( + model_name=model, + name="end", + field=django_interval.fields.FuzzyDateParserField( + blank=True, max_length=255, null=True, verbose_name="End" + ), + ), +] +entities = ["event", "institution", "person", "place", "work"] +relations = [ + "hatreligionszugehoerigkeit", + "personeventlegacyrelation", + "personinstitutionlegacyrelation", + "personpersonlegacyrelation", + "institutioninstitutionlegacyrelation", + "personplacelegacyrelation", + "personworklegacyrelation", + "placeplacelegacyrelation", + "wargeschwistervon", + "warschwagerschwaegerinvon", + "warschwiegersohnschwiegertochtervon", + "warverwandtmit", + "hattealstrauzeugenzeugin", + "warpatenkindvon", + "dissertiertebeiunter", + "wurdegeborenin", + "starbin", + "erhieltausbildungin", + "wirkteforschtehieltsichaufin", + "studiertelerntean", + "habilitiertesichan", + "warassistentinan", + "warprivatdozentinan", + "warotitoprofessorinan", + "waraotitaoprofessorinan", + "warhonorarprofessorinan", + "warehrendoktorinan", + "wartaetigfuerwirkteanbei", + "warmitgruenderinvon", + "hatteleitungsfunktionan", + "warmitgliedvon", + "wargrossvatermuttervon", + "warrektorinan", + "wardekaninan", + "promoviertean", + "kaempfteinbei", + "warprofessorinan", + "graduiertean", + "mitbiographiertunter", + "warhonorardozentinan", + "hatteleitungsfunktionbei", + "nahmteilan", + "warelternteilvon", + "warschuelerinvon", + "warverheiratetmit", + "standinkontaktmit", + "arbeitetezusammenmit", + "wurdeerhobenin", + "wargeburtstitelvon", + "fandstattin", +] +allmodels = ( + entities + + relations + + [f"version{entity}" for entity in entities] + + [f"version{relation}" for relation in relations] +) + + +class Migration(migrations.Migration): + dependencies = [ + ("apis_ontology", "0044_person_alternative_names_new_and_more"), + ] + + operations = [item for model in allmodels for item in migration_list(model)] diff --git a/apis_ontology/models.py b/apis_ontology/models.py index d31befb..ab3e47b 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -6,16 +6,28 @@ from django.utils.translation import gettext_lazy as _ from apis_core.apis_entities.models import AbstractEntity -from apis_core.core.models import LegacyDateMixin from apis_core.utils.helpers import create_object_from_uri from apis_core.generic.abc import GenericModel from apis_core.apis_entities.abc import E53_Place from apis_core.history.models import VersionMixin from django_json_editor_field.fields import JSONEditorField +from django_interval.fields import FuzzyDateParserField from auditlog.registry import auditlog +class LegacyDateMixin(models.Model): + start = FuzzyDateParserField( + max_length=255, blank=True, null=True, verbose_name=_("Start") + ) + end = FuzzyDateParserField( + max_length=255, blank=True, null=True, verbose_name=_("End") + ) + + class Meta: + abstract = True + + class OEBLBaseEntity: pass diff --git a/apis_ontology/settings.py b/apis_ontology/settings.py index 59607e4..5558610 100644 --- a/apis_ontology/settings.py +++ b/apis_ontology/settings.py @@ -14,6 +14,7 @@ INSTALLED_APPS += ["auditlog", "apis_acdhch_django_auditlog"] INSTALLED_APPS.remove("apis_core.apis_relations") INSTALLED_APPS += ["django_json_editor_field"] +INSTALLED_APPS += ["django_interval"] ROOT_URLCONF = "apis_ontology.urls" diff --git a/apis_ontology/urls.py b/apis_ontology/urls.py index cc766c5..7fd6d1d 100644 --- a/apis_ontology/urls.py +++ b/apis_ontology/urls.py @@ -11,3 +11,4 @@ urlpatterns += [ path("", include("apis_acdhch_django_auditlog.urls")), ] +urlpatterns += [path("", include("django_interval.urls"))] diff --git a/pyproject.toml b/pyproject.toml index a6731fa..1d28174 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ apis-acdhch-default-settings = "1.8.0" django-auditlog = "^3.0.0" apis-acdhch-django-auditlog = "^0.2.0" django-json-editor-field = "^0.4.0" +django-interval = "^0.2.3" [tool.poetry.group.dev.dependencies] ruff = "^0.8.0"