From 38451df357cb480a9e26d8d2457767b6e5003b78 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Mon, 9 Jan 2023 08:57:49 +0000 Subject: [PATCH] Remove dependency on moderation [#80] --- djangocms_version_locking/monkeypatch/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/djangocms_version_locking/monkeypatch/models.py b/djangocms_version_locking/monkeypatch/models.py index 74fe33b..067632d 100644 --- a/djangocms_version_locking/monkeypatch/models.py +++ b/djangocms_version_locking/monkeypatch/models.py @@ -1,6 +1,9 @@ from django.utils.translation import gettext_lazy as _ -from djangocms_moderation import models as moderation_model +try: + from djangocms_moderation import models as moderation_model +except ImportError: + moderation_model = None from djangocms_moderation.helpers import ( get_moderated_children_from_placeholder, ) @@ -99,4 +102,5 @@ def _add_nested_children(self, version, parent_node): return added_items -moderation_model.ModerationCollection._add_nested_children = _add_nested_children +if moderation_model: + moderation_model.ModerationCollection._add_nested_children = _add_nested_children