From 32e18946c5c23f49ffc4b14688402ae4a93d7bcf Mon Sep 17 00:00:00 2001 From: Alessio Tognan Date: Mon, 15 Jul 2024 17:25:39 +0200 Subject: [PATCH 1/3] fix: inherited fields with modeltranslation >= 0.19 --- wagtail_modeltranslation/patch_wagtailadmin.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wagtail_modeltranslation/patch_wagtailadmin.py b/wagtail_modeltranslation/patch_wagtailadmin.py index f0171ac..96d6f6b 100644 --- a/wagtail_modeltranslation/patch_wagtailadmin.py +++ b/wagtail_modeltranslation/patch_wagtailadmin.py @@ -70,7 +70,7 @@ def __init__(self, model): WagtailTranslator._patched_models.append(model) def _patch_fields(self, model): - translation_registered_fields = translator.get_options_for_model(model).fields + translation_registered_fields = translator.get_options_for_model(model).all_fields model_fields = model._meta.get_fields() for field in model_fields: @@ -108,7 +108,7 @@ def _patch_page_models(self, model): # SEARCH FIELDS PATCHING - translation_registered_fields = translator.get_options_for_model(model).fields + translation_registered_fields = translator.get_options_for_model(model).all_fields for field in model.search_fields: # Check if the field is a SearchField and if it is one of the fields registered for translation @@ -170,7 +170,7 @@ def _patch_other_models(self, model): def _patch_ObjectList(self, obj_list, model): translation_registered_fields = translator.get_options_for_model( model - ).fields + ).all_fields panels = list( filter( lambda field: field.field_name not in translation_registered_fields, @@ -206,7 +206,7 @@ def _patch_panels(self, panels_list, related_model=None): def _patch_simple_panel(self, model, original_panel): panel_class = original_panel.__class__ translated_panels = [] - translation_registered_fields = translator.get_options_for_model(model).fields + translation_registered_fields = translator.get_options_for_model(model).all_fields # If the panel field is not registered for translation # the original one is returned @@ -307,7 +307,7 @@ def _patch_inline_panel(self, model, panel): panels = extract_panel_definitions_from_model_class(related_model) translation_registered_fields = translator.get_options_for_model( related_model - ).fields + ).all_fields panels = list( filter( lambda field: field.field_name From ed201a4290332d32f0a20b915fd3a459cf0fb586 Mon Sep 17 00:00:00 2001 From: Alessio Tognan Date: Mon, 15 Jul 2024 17:25:55 +0200 Subject: [PATCH 2/3] chore: update minimum version of django-modeltranslation --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 285c0f8..b3a07ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ classifiers = [ python = "^3.8" Django = ">=4.2" wagtail = ">=5.2,<=7.0" -django-modeltranslation = ">=0.17" +django-modeltranslation = ">=0.19" [tool.poetry.dev-dependencies] bump2version = "^1.0.1" From a4863c23f1ae0030172c91d05de5a02dd3907c41 Mon Sep 17 00:00:00 2001 From: Alessio Tognan Date: Fri, 18 Oct 2024 17:15:20 +0200 Subject: [PATCH 3/3] fix: use django-modeltranslation 0.19 in CI --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 68888de..af9258f 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -37,7 +37,7 @@ jobs: strategy: matrix: python: ["3.8", "3.9", "3.10", "3.11", "3.12"] - django-modeltranslation: ["0.17", "0.18"] + django-modeltranslation: ["0.19"] wagtail: ["5.2", "6.0"] database: ["sqlite", "postgres", "mysql"] env: