Skip to content

Commit

Permalink
refactor(models,filters,forms,tables,api): rename ArrayFields
Browse files Browse the repository at this point in the history
Remove 'new_' prefix from names of Expression
and Character entity ArrayFields so their names
match those of the MultiSelectFields they replaced.
  • Loading branch information
koeaw committed Sep 2, 2024
1 parent 11e77d0 commit 3cb27f8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
6 changes: 3 additions & 3 deletions apis_ontology/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def get_queryset(self):
title="title",
subtitle="subtitle",
edition="edition",
edition_type="new_edition_type",
edition_type="edition_type",
language="language",
publication_date="publication_date_iso_formatted",
publisher="publisher",
Expand Down Expand Up @@ -324,7 +324,7 @@ def get_queryset(self):
title="title",
subtitle="subtitle",
edition="edition",
edition_type="new_edition_type",
edition_type="edition_type",
language="language",
publication_date="publication_date_iso_formatted",
publisher="publisher",
Expand All @@ -342,7 +342,7 @@ def get_queryset(self):
surname="surname",
fallback_name="fallback_name",
relevancy="relevancy",
fictionality="new_fictionality",
fictionality="fictionality",
)
)

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,33 @@
# 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',
),
]
4 changes: 2 additions & 2 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ class EditionTypes(models.TextChoices):
help_text=_('Eingabe muss im Format "X-Y" erfolgen, z.B. 5-12'),
)

new_edition_type = ArrayField(
edition_type = ArrayField(
base_field=models.CharField(
max_length=255,
choices=EditionTypes.choices,
Expand Down Expand Up @@ -902,7 +902,7 @@ class CharacterFictionality(models.TextChoices):
help_text=_("Bedeutsamkeit für den Text, Erzählfokus"),
)

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

0 comments on commit 3cb27f8

Please sign in to comment.