Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove remaining MultiSelectFields, rename new ArrayFields to match old names #184

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions apis_ontology/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions apis_ontology/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}


Expand Down Expand Up @@ -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",
)
Expand Down
8 changes: 4 additions & 4 deletions apis_ontology/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
@@ -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",
),
]
Original file line number Diff line number Diff line change
@@ -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",
),
]
25 changes: 2 additions & 23 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions apis_ontology/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"))
Expand Down Expand Up @@ -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):
Expand Down
Loading