diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index f1e63062..5dded14e 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,6 +4,8 @@ Changelog
Unreleased
==========
+fix: Replace SortableAdminMixin by SortableAdminBase for WorkflowAdmin
+fix: Restore "In Collection" button in the toolbar
2.2.1 (2024-07-02)
==================
diff --git a/djangocms_moderation/cms_toolbars.py b/djangocms_moderation/cms_toolbars.py
index 7679807a..a99a7b66 100644
--- a/djangocms_moderation/cms_toolbars.py
+++ b/djangocms_moderation/cms_toolbars.py
@@ -54,7 +54,7 @@ def _add_moderation_buttons(self):
if not helpers.is_registered_for_moderation(self.toolbar.obj):
return
- if self._is_versioned() and self.toolbar.edit_mode_active:
+ if self._is_versioned() and (self.toolbar.edit_mode_active or self.toolbar.preview_mode_active):
moderation_request = helpers.get_active_moderation_request(self.toolbar.obj)
if moderation_request:
title, url = helpers.get_moderation_button_title_and_url(
diff --git a/djangocms_moderation/monkeypatch.py b/djangocms_moderation/monkeypatch.py
index a439850e..a1ad0f06 100644
--- a/djangocms_moderation/monkeypatch.py
+++ b/djangocms_moderation/monkeypatch.py
@@ -120,6 +120,17 @@ def inner(self, obj, request):
return inner
+def _check_registered_for_moderation(message):
+ """
+ Fail check if object is registered for moderation
+ """
+ def inner(version, user):
+ if is_registered_for_moderation(version.content):
+ raise ConditionFailed(message)
+
+ return inner
+
+
admin.VersionAdmin._get_publish_link = _get_publish_link(
admin.VersionAdmin._get_publish_link
)
@@ -152,5 +163,8 @@ def inner(self, obj, request):
_("Cannot edit a version in an active moderation collection")
)
]
+models.Version.check_publish += [
+ _check_registered_for_moderation(_("Content cannot be published directly. Use the moderation process."))
+]
fields.PlaceholderRelationField.default_checks += [_is_placeholder_review_unlocked]
diff --git a/tests/test_admin.py b/tests/test_admin.py
index 32dbd321..2c44b403 100644
--- a/tests/test_admin.py
+++ b/tests/test_admin.py
@@ -440,3 +440,11 @@ def test_workflow_admin_renders_correctly(self):
# django-admin-sortable2 injected its inputs
self.assertContains(result, '')
self.assertContains(result, '