Skip to content

Commit

Permalink
feat(models): add LanguageMixin to Work, Expression
Browse files Browse the repository at this point in the history
Add select field for language to Work, Expression
entities via new LanguageMixin. TextChoices use
ISO 639-3 codes for values, German verbose names
for labels (+ 2-letter codes for variable names).
  • Loading branch information
koeaw committed Mar 28, 2024
1 parent ee1c888 commit 5d40b5b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
42 changes: 42 additions & 0 deletions apis_ontology/migrations/0047_expression_language_work_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 4.2.11 on 2024-03-28 12:13

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("apis_ontology", "0046_expression_isbn"),
]

operations = [
migrations.AddField(
model_name="expression",
name="language",
field=models.CharField(
blank=True,
choices=[
("deu", "Deutsch"),
("eng", "Englisch"),
("fra", "Französisch"),
],
default="",
max_length=3,
verbose_name="Sprache",
),
),
migrations.AddField(
model_name="work",
name="language",
field=models.CharField(
blank=True,
choices=[
("deu", "Deutsch"),
("eng", "Englisch"),
("fra", "Französisch"),
],
default="",
max_length=3,
verbose_name="Sprache",
),
),
]
9 changes: 7 additions & 2 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class Meta:


@reversion.register(follow=["rootobject_ptr"])
class Work(TitlesMixin, StatusMixin, AbstractEntity):
class Work(TitlesMixin, LanguageMixin, StatusMixin, AbstractEntity):
"""
The abstract notion of an intellectual creation, irrespective
of its exact transmitted version, language or other form.
Expand Down Expand Up @@ -535,7 +535,12 @@ class Meta:

@reversion.register(follow=["rootobject_ptr"])
class Expression(
TitlesMixin, DescriptionMixin, NotesMixin, StatusMixin, AbstractEntity
TitlesMixin,
DescriptionMixin,
LanguageMixin,
NotesMixin,
StatusMixin,
AbstractEntity,
):
"""
A concrete representation of a given Work,
Expand Down

0 comments on commit 5d40b5b

Please sign in to comment.