diff --git a/apis_ontology/api/serializers.py b/apis_ontology/api/serializers.py index cd03c16..9386bff 100644 --- a/apis_ontology/api/serializers.py +++ b/apis_ontology/api/serializers.py @@ -66,7 +66,9 @@ class ExpressionDataSerializer(serializers.ModelSerializer): place_of_publication = PlaceDataSerializer( required=False, allow_null=True, many=True ) - edition_type = serializers.SerializerMethodField() + edition_type = serializers.ListField( + child=serializers.CharField(allow_null=True), required=False, allow_empty=True + ) language = serializers.ListField( child=serializers.CharField(allow_null=True), required=False, allow_empty=True ) @@ -84,11 +86,6 @@ class Meta: "place_of_publication", ] - def get_edition_type(self, obj) -> list["str"]: - edition_type_str = obj.get("edition_type", None) - edition_types = list(filter(None, edition_type_str.split(","))) - return get_choices_labels(edition_types, Expression.EditionTypes) - class SimpleDetailSerializer(serializers.Serializer): id = serializers.IntegerField() @@ -126,9 +123,21 @@ class RelatedWorksDict(TypedDict): class CharacterDataSerializer(serializers.ModelSerializer): + fictionality = serializers.ListField( + child=serializers.CharField(allow_null=True), required=False, allow_empty=True + ) + class Meta: model = Character - exclude = ["self_contenttype", "data_source"] + fields = [ + "forename", + "surname", + "fallback_name", + "alternative_name", + "description", + "relevancy", + "fictionality", + ] class ArchiveDataSerializer(serializers.ModelSerializer): diff --git a/apis_ontology/filtersets.py b/apis_ontology/filtersets.py index 745f5b5..139c575 100644 --- a/apis_ontology/filtersets.py +++ b/apis_ontology/filtersets.py @@ -200,14 +200,14 @@ class PersonFilterSet(BaseEntityFilterSet, PersonSearch): class CharacterFilterSet(BaseEntityFilterSet, PersonSearch): - new_fictionality = django_filters.MultipleChoiceFilter( + fictionality = django_filters.MultipleChoiceFilter( choices=Character.CharacterFictionality.choices, lookup_expr="icontains", ) class Meta(BaseEntityFilterSet.Meta): fields = { - "new_fictionality": ["icontains"], + "fictionality": ["icontains"], } @@ -279,7 +279,7 @@ class VersionWorkFilterSet(WorkFilterSet): class ExpressionFilterSet(BaseEntityFilterSet, LanguageMixinFilter, TitlesSearch): - new_edition_type = django_filters.MultipleChoiceFilter( + edition_type = django_filters.MultipleChoiceFilter( choices=Expression.EditionTypes.choices, lookup_expr="icontains", ) diff --git a/apis_ontology/forms.py b/apis_ontology/forms.py index b1edc5e..77b0420 100644 --- a/apis_ontology/forms.py +++ b/apis_ontology/forms.py @@ -71,16 +71,16 @@ class WorkForm(GenericModelForm, LanguageForm): class ExpressionForm(GenericModelForm, LanguageForm): - new_edition_type = forms.MultipleChoiceField( + edition_type = forms.MultipleChoiceField( required=False, choices=Expression.EditionTypes.choices, - label=Expression._meta.get_field("new_edition_type").verbose_name, + label=Expression._meta.get_field("edition_type").verbose_name, ) class CharacterForm(GenericModelForm): - new_fictionality = forms.MultipleChoiceField( + fictionality = forms.MultipleChoiceField( required=False, choices=Character.CharacterFictionality.choices, - label=Character._meta.get_field("new_fictionality").verbose_name, + label=Character._meta.get_field("fictionality").verbose_name, ) diff --git a/apis_ontology/migrations/0077_remove_character_fictionality_and_more.py b/apis_ontology/migrations/0077_remove_character_fictionality_and_more.py new file mode 100644 index 0000000..46abcd7 --- /dev/null +++ b/apis_ontology/migrations/0077_remove_character_fictionality_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.15 on 2024-09-02 09:07 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("apis_ontology", "0076_migrate_multiselectfield_data_to_arrayfields"), + ] + + operations = [ + migrations.RemoveField( + model_name="character", + name="fictionality", + ), + migrations.RemoveField( + model_name="expression", + name="edition_type", + ), + migrations.RemoveField( + model_name="versioncharacter", + name="fictionality", + ), + migrations.RemoveField( + model_name="versionexpression", + name="edition_type", + ), + ] diff --git a/apis_ontology/migrations/0078_rename_new_fictionality_character_fictionality_and_more.py b/apis_ontology/migrations/0078_rename_new_fictionality_character_fictionality_and_more.py new file mode 100644 index 0000000..b08772f --- /dev/null +++ b/apis_ontology/migrations/0078_rename_new_fictionality_character_fictionality_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 4.2.15 on 2024-09-02 09:34 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("apis_ontology", "0077_remove_character_fictionality_and_more"), + ] + + operations = [ + migrations.RenameField( + model_name="character", + old_name="new_fictionality", + new_name="fictionality", + ), + migrations.RenameField( + model_name="expression", + old_name="new_edition_type", + new_name="edition_type", + ), + migrations.RenameField( + model_name="versioncharacter", + old_name="new_fictionality", + new_name="fictionality", + ), + migrations.RenameField( + model_name="versionexpression", + old_name="new_edition_type", + new_name="edition_type", + ), + ] diff --git a/apis_ontology/models.py b/apis_ontology/models.py index 62ed4a2..eeff1d3 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -12,7 +12,6 @@ from django.core.validators import validate_slug from django.db import models from django.utils.translation import gettext_lazy as _ -from multiselectfield import MultiSelectField logger = logging.getLogger(__name__) @@ -667,17 +666,7 @@ class EditionTypes(models.TextChoices): help_text=_('Eingabe muss im Format "X-Y" erfolgen, z.B. 5-12'), ) - edition_type = MultiSelectField( - max_length=255, - choices=EditionTypes.choices, - blank=True, - default="", - editable=False, - verbose_name=_("Ausgabetyp (deprecated)"), - help_text=_("Zur Markierung speziell relevanter Ausgaben"), - ) - - new_edition_type = ArrayField( + edition_type = ArrayField( base_field=models.CharField( max_length=255, choices=EditionTypes.choices, @@ -912,17 +901,7 @@ class CharacterFictionality(models.TextChoices): help_text=_("Bedeutsamkeit für den Text, Erzählfokus"), ) - fictionality = MultiSelectField( - max_length=255, - choices=CharacterFictionality.choices, - blank=False, - default="", - editable=False, - verbose_name=_("Erfindungsgrad (deprecated)"), - help_text=_("Faktizität vs. Fiktionalität"), - ) - - new_fictionality = ArrayField( + fictionality = ArrayField( base_field=models.CharField( max_length=255, choices=CharacterFictionality.choices, diff --git a/apis_ontology/tables.py b/apis_ontology/tables.py index b3e1319..222eb5f 100644 --- a/apis_ontology/tables.py +++ b/apis_ontology/tables.py @@ -91,11 +91,11 @@ class ExpressionTable(FullTitleMixin, BaseEntityTable, tables.Table): class Meta(BaseEntityTable.Meta): model = Expression fields = [ - "new_edition_type", + "edition_type", "publication_date_iso_formatted", "publication_date_manual_input", ] - order_by = ("full_title", "publication_date_iso_formatted", "new_edition_type") + order_by = ("full_title", "publication_date_iso_formatted", "edition_type") publication_date_iso_formatted = tables.Column(verbose_name=_("Datum (ISO)")) publication_date_manual_input = tables.Column(verbose_name=_("Datum (manuell)")) @@ -126,7 +126,7 @@ class Meta(BaseEntityTable.Meta): class CharacterTable(FullNameMixin, BaseEntityTable): class Meta(BaseEntityTable.Meta): model = Character - fields = ["relevancy", "new_fictionality"] + fields = ["relevancy", "fictionality"] class MetaCharacterTable(BaseEntityTable):