From 5d40b5b410756189e150ebb9c9777b4c02e88d1c Mon Sep 17 00:00:00 2001 From: KK Date: Thu, 28 Mar 2024 13:06:16 +0100 Subject: [PATCH] feat(models): add LanguageMixin to Work, Expression 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). --- .../0047_expression_language_work_language.py | 42 +++++++++++++++++++ apis_ontology/models.py | 9 +++- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 apis_ontology/migrations/0047_expression_language_work_language.py diff --git a/apis_ontology/migrations/0047_expression_language_work_language.py b/apis_ontology/migrations/0047_expression_language_work_language.py new file mode 100644 index 0000000..daceb91 --- /dev/null +++ b/apis_ontology/migrations/0047_expression_language_work_language.py @@ -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", + ), + ), + ] diff --git a/apis_ontology/models.py b/apis_ontology/models.py index 5fae7e9..d0a29d8 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -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. @@ -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,