Skip to content

Commit

Permalink
Add work
Browse files Browse the repository at this point in the history
  • Loading branch information
gythaogg committed Apr 22, 2024
1 parent 5b2338c commit b4686f7
Show file tree
Hide file tree
Showing 2 changed files with 387 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,353 @@
# Generated by Django 4.2.11 on 2024-04-22 06:24

import apis_core.generic.abc
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import simple_history.models


class Migration(migrations.Migration):

dependencies = [
("apis_metainfo", "0012_remove_rootobject_deprecated_name"),
("contenttypes", "0002_remove_content_type_name"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("apis_ontology", "0003_alter_person_options"),
]

operations = [
migrations.CreateModel(
name="VersionWork",
fields=[
(
"rootobject_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="apis_metainfo.rootobject",
),
),
(
"id",
models.IntegerField(
auto_created=True, blank=True, db_index=True, verbose_name="ID"
),
),
("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),
),
("comments", models.TextField(blank=True, null=True)),
(
"alternative_names",
models.TextField(
blank=True, null=True, verbose_name="Alternative names"
),
),
(
"external_links",
models.TextField(
blank=True, null=True, verbose_name="External links"
),
),
(
"review",
models.BooleanField(
default=False,
help_text="Should be set to True, if the data record holds up quality standards.",
),
),
(
"notes",
models.TextField(blank=True, null=True, verbose_name="Notes"),
),
("published", models.BooleanField(default=False)),
(
"subject",
models.CharField(
blank=True, max_length=255, null=True, verbose_name="subject"
),
),
(
"name",
models.CharField(
blank=True, default="", max_length=255, verbose_name="Name"
),
),
(
"sde_dge_ref",
models.CharField(
blank=True,
max_length=25,
null=True,
verbose_name="Derge reference",
),
),
(
"original_language",
models.CharField(
blank=True,
choices=[
("Sanskrit", "Sanskrit"),
("Tibetan", "Tibetan"),
("Tangut", "Tangut"),
("Other", "Other"),
],
max_length=10,
null=True,
),
),
(
"isExtant",
models.BooleanField(default=True, verbose_name="Is extant"),
),
("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,
),
),
(
"self_contenttype",
models.ForeignKey(
blank=True,
db_constraint=False,
editable=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="contenttypes.contenttype",
),
),
],
options={
"verbose_name": "Version",
"verbose_name_plural": "Versions",
"ordering": ("-history_date", "-history_id"),
"get_latest_by": ("history_date", "history_id"),
},
bases=(
simple_history.models.HistoricalChanges,
models.Model,
apis_core.generic.abc.GenericModel,
),
),
migrations.CreateModel(
name="Work",
fields=[
(
"rootobject_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="apis_metainfo.rootobject",
),
),
("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"
),
),
("comments", models.TextField(blank=True, null=True)),
(
"alternative_names",
models.TextField(
blank=True, null=True, verbose_name="Alternative names"
),
),
(
"external_links",
models.TextField(
blank=True, null=True, verbose_name="External links"
),
),
(
"review",
models.BooleanField(
default=False,
help_text="Should be set to True, if the data record holds up quality standards.",
),
),
(
"notes",
models.TextField(blank=True, null=True, verbose_name="Notes"),
),
("published", models.BooleanField(default=False)),
(
"subject",
models.CharField(
blank=True, max_length=255, null=True, verbose_name="subject"
),
),
(
"name",
models.CharField(
blank=True, default="", max_length=255, verbose_name="Name"
),
),
(
"sde_dge_ref",
models.CharField(
blank=True,
max_length=25,
null=True,
verbose_name="Derge reference",
),
),
(
"original_language",
models.CharField(
blank=True,
choices=[
("Sanskrit", "Sanskrit"),
("Tibetan", "Tibetan"),
("Tangut", "Tangut"),
("Other", "Other"),
],
max_length=10,
null=True,
),
),
(
"isExtant",
models.BooleanField(default=True, verbose_name="Is extant"),
),
(
"collection",
models.ManyToManyField(
editable=False, to="apis_metainfo.collection"
),
),
],
options={
"verbose_name": "work",
"verbose_name_plural": "Works",
},
bases=("apis_metainfo.rootobject", models.Model),
),
migrations.CreateModel(
name="VersionWork_collection",
fields=[
(
"id",
models.IntegerField(
auto_created=True, blank=True, db_index=True, verbose_name="ID"
),
),
("m2m_history_id", models.AutoField(primary_key=True, serialize=False)),
(
"collection",
models.ForeignKey(
blank=True,
db_constraint=False,
db_tablespace="",
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="apis_metainfo.collection",
),
),
(
"history",
models.ForeignKey(
db_constraint=False,
on_delete=django.db.models.deletion.DO_NOTHING,
to="apis_ontology.versionwork",
),
),
(
"work",
models.ForeignKey(
blank=True,
db_constraint=False,
db_tablespace="",
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="apis_ontology.work",
),
),
],
options={
"verbose_name": "VersionWork_collection",
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
]
34 changes: 34 additions & 0 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,40 @@ def __str__(self):
return f"{self.label}"


class Work(
VersionMixin, LegacyStuffMixin, LegacyDateMixin, TibScholEntityMixin, AbstractEntity
):
class_uri = "http://id.loc.gov/ontologies/bibframe/Work"
LANGUAGES = [
("Sanskrit", "Sanskrit"),
("Tibetan", "Tibetan"),
("Tangut", "Tangut"),
("Other", "Other"),
]
subject = models.CharField(
max_length=255,
blank=True,
null=True,
verbose_name="subject",
) # should be a controlled vocabulary field

name = models.CharField(max_length=255, blank=True, default="", verbose_name="Name")
sde_dge_ref = models.CharField(
max_length=25, blank=True, null=True, verbose_name="Derge reference"
)
original_language = models.CharField(
max_length=10, choices=LANGUAGES, blank=True, null=True
)
isExtant = models.BooleanField(default=True, verbose_name="Is extant")

class Meta:
verbose_name = _("work")
verbose_name_plural = _("Works")

def __str__(self):
return f"{self.name}"


class ZoteroEntry(GenericModel, models.Model):
zoteroId = models.CharField(max_length=255, verbose_name="Zotero ID")
shortTitle = models.TextField(blank=True, null=True, verbose_name="Short title")
Expand Down

0 comments on commit b4686f7

Please sign in to comment.