Skip to content

Commit

Permalink
Merge pull request #258 from easherma/bindtomodel-version
Browse files Browse the repository at this point in the history
different bindto model function depending on wagtail version
  • Loading branch information
DiogoMarques29 authored Oct 25, 2019
2 parents 1366c86 + a92d287 commit 18ed10a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wagtail_modeltranslation/patch_wagtailadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
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
from wagtail import VERSION

logger = logging.getLogger('wagtail.core')

Expand Down Expand Up @@ -140,8 +141,11 @@ def _patch_other_models(self, model):
translation_registered_fields = translator.get_options_for_model(model).fields
panels = filter(lambda field: field.field_name not in translation_registered_fields, panels)
edit_handler = ObjectList(panels)
if VERSION < (2, 5):
SNIPPET_EDIT_HANDLERS[model] = edit_handler.bind_to_model(model)
else:
SNIPPET_EDIT_HANDLERS[model] = edit_handler.bind_to(model=model)

SNIPPET_EDIT_HANDLERS[model] = edit_handler.bind_to_model(model)

def _patch_panels(self, panels_list, related_model=None):
"""
Expand Down

0 comments on commit 18ed10a

Please sign in to comment.