-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #374
- Loading branch information
Showing
4 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
from apis_core.generic.importers import GenericModelImporter | ||
from apis_core.utils.helpers import create_object_from_uri | ||
from apis_ontology.models import FandStattIn, Place | ||
|
||
|
||
class PersonImporter(GenericModelImporter): | ||
def mangle_data(self, data): | ||
if "profession" in data: | ||
del data["profession"] | ||
return data | ||
|
||
|
||
class EventImporter(GenericModelImporter): | ||
def create_instance(self): | ||
data = self.get_data(drop_unknown_fields=False) | ||
modelfields = [field.name for field in self.model._meta.fields] | ||
data_croped = {key: data[key] for key in data if key in modelfields} | ||
subj = self.model.objects.create(**data_croped) | ||
if "related_place" in data: | ||
place = create_object_from_uri(data["related_place"], Place) | ||
FandStattIn.objects.create(subj=subj, obj=place) | ||
return subj |
213 changes: 213 additions & 0 deletions
213
apis_ontology/migrations/0043_fandstattin_versionfandstattin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
# Generated by Django 5.1.3 on 2024-11-25 10:44 | ||
|
||
import apis_core.generic.abc | ||
import django.db.models.deletion | ||
import simple_history.models | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("apis_ontology", "0042_nobility_wargeburtstitelvon_wurdeerhobenin_and_more"), | ||
("contenttypes", "0002_remove_content_type_name"), | ||
("relations", "0001_initial"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="FandStattIn", | ||
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", | ||
), | ||
), | ||
("start_date", models.DateField(blank=True, editable=False, null=True)), | ||
( | ||
"start_start_date", | ||
models.DateField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"start_end_date", | ||
models.DateField(blank=True, editable=False, null=True), | ||
), | ||
("end_date", models.DateField(blank=True, editable=False, null=True)), | ||
( | ||
"end_start_date", | ||
models.DateField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"end_end_date", | ||
models.DateField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"start_date_written", | ||
models.CharField( | ||
blank=True, max_length=255, null=True, verbose_name="Start" | ||
), | ||
), | ||
( | ||
"end_date_written", | ||
models.CharField( | ||
blank=True, max_length=255, null=True, verbose_name="End" | ||
), | ||
), | ||
( | ||
"review", | ||
models.BooleanField( | ||
default=False, | ||
editable=False, | ||
help_text="Should be set to True, if the data record holds up quality standards.", | ||
), | ||
), | ||
( | ||
"status", | ||
models.CharField( | ||
blank=True, editable=False, max_length=100, null=True | ||
), | ||
), | ||
("references", models.TextField(blank=True, null=True)), | ||
("notes", models.TextField(blank=True, null=True)), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("relations.relation", models.Model), | ||
), | ||
migrations.CreateModel( | ||
name="VersionFandStattIn", | ||
fields=[ | ||
( | ||
"relation_ptr", | ||
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="relations.relation", | ||
), | ||
), | ||
( | ||
"id", | ||
models.IntegerField( | ||
auto_created=True, blank=True, db_index=True, verbose_name="ID" | ||
), | ||
), | ||
("subj_object_id", models.PositiveIntegerField()), | ||
("obj_object_id", models.PositiveIntegerField()), | ||
("start_date", models.DateField(blank=True, editable=False, null=True)), | ||
( | ||
"start_start_date", | ||
models.DateField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"start_end_date", | ||
models.DateField(blank=True, editable=False, null=True), | ||
), | ||
("end_date", models.DateField(blank=True, editable=False, null=True)), | ||
( | ||
"end_start_date", | ||
models.DateField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"end_end_date", | ||
models.DateField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"start_date_written", | ||
models.CharField( | ||
blank=True, max_length=255, null=True, verbose_name="Start" | ||
), | ||
), | ||
( | ||
"end_date_written", | ||
models.CharField( | ||
blank=True, max_length=255, null=True, verbose_name="End" | ||
), | ||
), | ||
( | ||
"version_tag", | ||
models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
( | ||
"review", | ||
models.BooleanField( | ||
default=False, | ||
editable=False, | ||
help_text="Should be set to True, if the data record holds up quality standards.", | ||
), | ||
), | ||
( | ||
"status", | ||
models.CharField( | ||
blank=True, editable=False, max_length=100, null=True | ||
), | ||
), | ||
("references", models.TextField(blank=True, null=True)), | ||
("notes", models.TextField(blank=True, null=True)), | ||
("history_id", models.AutoField(primary_key=True, serialize=False)), | ||
("history_date", models.DateTimeField(db_index=True)), | ||
("history_change_reason", models.CharField(max_length=100, null=True)), | ||
( | ||
"history_type", | ||
models.CharField( | ||
choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], | ||
max_length=1, | ||
), | ||
), | ||
( | ||
"history_user", | ||
models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="+", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"obj_content_type", | ||
models.ForeignKey( | ||
blank=True, | ||
db_constraint=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="+", | ||
to="contenttypes.contenttype", | ||
), | ||
), | ||
( | ||
"subj_content_type", | ||
models.ForeignKey( | ||
blank=True, | ||
db_constraint=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="+", | ||
to="contenttypes.contenttype", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "historical fand statt in", | ||
"verbose_name_plural": "historical fand statt ins", | ||
"ordering": ("-history_date", "-history_id"), | ||
"get_latest_by": ("history_date", "history_id"), | ||
}, | ||
bases=( | ||
simple_history.models.HistoricalChanges, | ||
models.Model, | ||
apis_core.generic.abc.GenericModel, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
################################################# | ||
# Create an Event from GND # | ||
################################################# | ||
superclass = "apis_ontology.models.Event" | ||
regex = "https://d-nb.info.*" | ||
[[attributes]] | ||
# name | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?name | ||
WHERE { | ||
?subject a gndo:HistoricSingleEventOrEra ; | ||
gndo:preferredNameForTheSubjectHeading ?name . | ||
} | ||
""" | ||
[[attributes]] | ||
# start_date_written | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?start_date_written | ||
WHERE { | ||
?subject a gndo:HistoricSingleEventOrEra ; | ||
gndo:dateOfProduction ?start_date_written . | ||
} | ||
""" | ||
[[attributes]] | ||
# related_place | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?related_place | ||
WHERE { | ||
?subject a gndo:HistoricSingleEventOrEra ; | ||
gndo:place ?related_place . | ||
} | ||
""" |