Skip to content

Commit

Permalink
feat(models): add attributes and relations
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Oct 24, 2024
1 parent e902d9e commit 63bc167
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Generated by Django 5.1.2 on 2024-10-24 08:57

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apis_instance_nsvis', '0001_initial'),
('apis_metainfo', '0014_remove_uri_domain_remove_uri_loaded_and_more'),
('contenttypes', '0002_remove_content_type_name'),
('relations', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Collaboration',
fields=[
('relation_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='relations.relation')),
],
bases=('relations.relation',),
),
migrations.CreateModel(
name='LivesIn',
fields=[
('relation_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='relations.relation')),
],
bases=('relations.relation',),
),
migrations.CreateModel(
name='Membership',
fields=[
('relation_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='relations.relation')),
],
bases=('relations.relation',),
),
migrations.CreateModel(
name='WorksIn',
fields=[
('relation_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='relations.relation')),
],
bases=('relations.relation',),
),
migrations.RemoveField(
model_name='institution',
name='id',
),
migrations.RemoveField(
model_name='person',
name='id',
),
migrations.RemoveField(
model_name='place',
name='id',
),
migrations.AddField(
model_name='institution',
name='rootobject_ptr',
field=models.OneToOneField(auto_created=True, default=0, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='apis_metainfo.rootobject'),
preserve_default=False,
),
migrations.AddField(
model_name='person',
name='biography',
field=models.TextField(blank=True, verbose_name='Biography'),
),
migrations.AddField(
model_name='person',
name='rootobject_ptr',
field=models.OneToOneField(auto_created=True, default=0, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='apis_metainfo.rootobject'),
preserve_default=False,
),
migrations.AddField(
model_name='place',
name='rootobject_ptr',
field=models.OneToOneField(auto_created=True, default=0, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='apis_metainfo.rootobject'),
preserve_default=False,
),
migrations.AddField(
model_name='versioninstitution',
name='rootobject_ptr',
field=models.ForeignKey(auto_created=True, blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, parent_link=True, related_name='+', to='apis_metainfo.rootobject'),
),
migrations.AddField(
model_name='versioninstitution',
name='self_contenttype',
field=models.ForeignKey(blank=True, db_constraint=False, editable=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='contenttypes.contenttype'),
),
migrations.AddField(
model_name='versionperson',
name='biography',
field=models.TextField(blank=True, verbose_name='Biography'),
),
migrations.AddField(
model_name='versionperson',
name='rootobject_ptr',
field=models.ForeignKey(auto_created=True, blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, parent_link=True, related_name='+', to='apis_metainfo.rootobject'),
),
migrations.AddField(
model_name='versionperson',
name='self_contenttype',
field=models.ForeignKey(blank=True, db_constraint=False, editable=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='contenttypes.contenttype'),
),
migrations.AddField(
model_name='versionplace',
name='rootobject_ptr',
field=models.ForeignKey(auto_created=True, blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, parent_link=True, related_name='+', to='apis_metainfo.rootobject'),
),
migrations.AddField(
model_name='versionplace',
name='self_contenttype',
field=models.ForeignKey(blank=True, db_constraint=False, editable=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='contenttypes.contenttype'),
),
]
26 changes: 26 additions & 0 deletions apis_instance_nsvis/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from apis_core.apis_entities.abc import E53_Place, E21_Person
from apis_core.history.models import VersionMixin
from apis_core.apis_entities.models import AbstractEntity
from apis_core.relations.models import Relation

from auditlog.registry import auditlog

Expand All @@ -10,6 +13,8 @@ class NsvisMixin:


class Person(E21_Person, AbstractEntity, VersionMixin):
biography = models.TextField(blank=True, verbose_name=_("Biography"))

pass


Expand All @@ -18,9 +23,30 @@ class Place(E53_Place, AbstractEntity, VersionMixin):


class Institution(AbstractEntity, VersionMixin):
""" Zeitschriften, Verlage, Agenturen, Partei + Vorfeldorganisation """
pass


auditlog.register(Person, serialize_data=True)
auditlog.register(Place, serialize_data=True)
auditlog.register(Institution, serialize_data=True)


class Collaboration(Relation):
subj_model = Person
obj_model = Person


class Membership(Relation):
subj_model = Person
obj_model = Institution


class LivesIn(Relation):
subj_model = Person
obj_model = Place


class WorksIn(Relation):
subj_model = Person
obj_model = Place

0 comments on commit 63bc167

Please sign in to comment.