Skip to content

Commit

Permalink
Fix monkeypatch
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Aug 29, 2024
1 parent f8f9e62 commit ce22724
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions djangocms_moderation/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from cms.utils.urlutils import add_url_parameters

from djangocms_versioning import admin, models
from djangocms_versioning.conditions import Conditions
from djangocms_versioning.constants import DRAFT
from djangocms_versioning.exceptions import ConditionFailed
from djangocms_versioning.helpers import version_list_url
Expand Down Expand Up @@ -119,6 +120,15 @@ def inner(self, obj, request):

return inner

def _fail(message):
"""
Make a check condition fail always
"""
def inner(version, user):
raise ConditionFailed(message)

return inner


admin.VersionAdmin._get_publish_link = _get_publish_link(
admin.VersionAdmin._get_publish_link
Expand Down Expand Up @@ -152,5 +162,8 @@ def inner(self, obj, request):
_("Cannot edit a version in an active moderation collection")
)
]
models.Version.check_publish = Conditions([
_fail(_("Content cannot be published directly. Use the moderation process."))
])

fields.PlaceholderRelationField.default_checks += [_is_placeholder_review_unlocked]

0 comments on commit ce22724

Please sign in to comment.