Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

birger/django interval #407

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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)]
14 changes: 13 additions & 1 deletion apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions apis_ontology/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions apis_ontology/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
urlpatterns += [
path("", include("apis_acdhch_django_auditlog.urls")),
]
urlpatterns += [path("", include("django_interval.urls"))]
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading