mirror of
https://github.com/Hopiu/wagtail-modeltranslation.git
synced 2026-03-16 22:10:30 +00:00
Merge pull request #246 from msilvapor/master
Allows patching admin interface for all models registered for translation
This commit is contained in:
commit
58fdc7148b
2 changed files with 4 additions and 9 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -18,8 +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
|
||||
from wagtail.contrib.settings.views import get_setting_edit_handler
|
||||
|
||||
try:
|
||||
from wagtail.contrib.routable_page.models import RoutablePageMixin
|
||||
|
|
@ -32,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
|
||||
|
|
@ -45,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
|
||||
|
|
@ -262,9 +258,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 + '/')
|
||||
|
||||
|
|
@ -573,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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue