From 640d5202c94ff76198ed1d3582eba1b6bdc27a19 Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Thu, 6 Jun 2019 15:58:12 +0100 Subject: [PATCH 1/4] Linter fix --- wagtail_modeltranslation/patch_wagtailadmin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wagtail_modeltranslation/patch_wagtailadmin.py b/wagtail_modeltranslation/patch_wagtailadmin.py index f3184cb..70215fe 100644 --- a/wagtail_modeltranslation/patch_wagtailadmin.py +++ b/wagtail_modeltranslation/patch_wagtailadmin.py @@ -19,7 +19,6 @@ from modeltranslation import settings as mt_settings from modeltranslation.translator import translator, NotRegistered from modeltranslation.utils import build_localized_fieldname, get_language from wagtail.contrib.settings.models import BaseSetting -from wagtail.contrib.settings.views import get_setting_edit_handler try: from wagtail.contrib.routable_page.models import RoutablePageMixin @@ -262,9 +261,9 @@ def _localized_set_url_path(page, parent, language): # for the current language. If the value for the current language is invalid we get the one # for the default fallback language slug = getattr(page, localized_slug_field, None) or \ - getattr(page, default_localized_slug_field, None) or page.slug + getattr(page, default_localized_slug_field, None) or page.slug parent_url_path = getattr(parent, localized_url_path_field, None) or \ - getattr(parent, default_localized_url_path_field, None) or parent.url_path + getattr(parent, default_localized_url_path_field, None) or parent.url_path setattr(page, localized_url_path_field, parent_url_path + slug + '/') From bbe19792c9e4c5e49718ffcf049c7485fa9c393c Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Thu, 6 Jun 2019 15:59:25 +0100 Subject: [PATCH 2/4] Allows patching admin interface for all models registered for translation --- wagtail_modeltranslation/patch_wagtailadmin.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/wagtail_modeltranslation/patch_wagtailadmin.py b/wagtail_modeltranslation/patch_wagtailadmin.py index 70215fe..a31bf49 100644 --- a/wagtail_modeltranslation/patch_wagtailadmin.py +++ b/wagtail_modeltranslation/patch_wagtailadmin.py @@ -18,7 +18,6 @@ from django.utils.translation import ugettext_lazy as _ from modeltranslation import settings as mt_settings from modeltranslation.translator import translator, NotRegistered from modeltranslation.utils import build_localized_fieldname, get_language -from wagtail.contrib.settings.models import BaseSetting try: from wagtail.contrib.routable_page.models import RoutablePageMixin @@ -31,7 +30,6 @@ try: from wagtail.core.utils import WAGTAIL_APPEND_SLASH from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.search.index import SearchField - from wagtail.snippets.models import get_snippet_models from wagtail.snippets.views.snippets import SNIPPET_EDIT_HANDLERS except ImportError: from wagtail.contrib.wagtailroutablepage.models import RoutablePageMixin @@ -44,7 +42,6 @@ except ImportError: from wagtail.wagtailcore.utils import WAGTAIL_APPEND_SLASH from wagtail.wagtailimages.edit_handlers import ImageChooserPanel from wagtail.wagtailsearch.index import SearchField - from wagtail.wagtailsnippets.models import get_snippet_models from wagtail.wagtailsnippets.views.snippets import SNIPPET_EDIT_HANDLERS from wagtail_modeltranslation.settings import CUSTOM_SIMPLE_PANELS, CUSTOM_COMPOSED_PANELS, TRANSLATE_SLUGS from wagtail_modeltranslation.utils import compare_class_tree_depth @@ -572,5 +569,4 @@ def patch_wagtail_models(): registered_models.sort(key=compare_class_tree_depth) for model_class in registered_models: - if issubclass(model_class, Page) or model_class in get_snippet_models() or issubclass(model_class, BaseSetting): - WagtailTranslator(model_class) + WagtailTranslator(model_class) From 30a6ada4de7e9ff68b7d71584eaea7fbaf7e48db Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Thu, 6 Jun 2019 16:06:43 +0100 Subject: [PATCH 3/4] Fixes psycopg2 bug --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a97bd6c..bb3e3c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ before_script: install: - pip install --upgrade -q pip setuptools - if [[ $DB == mysql ]] && [[ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]]; then pip install -q mysql-python; elif [[ $DB == mysql ]] && [[ ${TRAVIS_PYTHON_VERSION:0:1} == "3" ]]; then pip install -q mysqlclient; fi - - if [[ $DB == postgres ]]; then pip install -q psycopg2; fi + - if [[ $DB == postgres ]]; then pip install -q psycopg2-binary<2.8; fi - pip install $WAGTAIL - pip install -e . script: From f1b04f92020e95fce969f359fdfe5cf4cc1798de Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Thu, 6 Jun 2019 16:14:48 +0100 Subject: [PATCH 4/4] Hotfix: fixes psycopg2 binary installation --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bb3e3c0..50fea6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ before_script: install: - pip install --upgrade -q pip setuptools - if [[ $DB == mysql ]] && [[ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]]; then pip install -q mysql-python; elif [[ $DB == mysql ]] && [[ ${TRAVIS_PYTHON_VERSION:0:1} == "3" ]]; then pip install -q mysqlclient; fi - - if [[ $DB == postgres ]]; then pip install -q psycopg2-binary<2.8; fi + - if [[ $DB == postgres ]]; then pip install -q 'psycopg2-binary<2.8'; fi - pip install $WAGTAIL - pip install -e . script: