Skip to content

Commit

Permalink
Patch _get_publish_link and check_publish
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Aug 30, 2024
1 parent ce495a6 commit 7a3af1a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion djangocms_moderation/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,35 @@ def inner(version, user):
return inner


def _get_publish_link(func):
"""
Monkey patch VersionAdmin's _get_publish_link to remove publish link,
if obj.content is registered with moderation
"""

def inner(self, obj, request):
input(f"{obj=}, {is_registered_for_moderation(obj.content)=}")
if is_registered_for_moderation(obj.content):
return ""
return func(self, obj, request)

return inner


def _check_registered_for_moderation(message):
"""
Fail check if object is registered for moderation
"""
def inner(version, user):
if not is_registered_for_moderation(version.content):
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
)
admin.VersionAdmin.get_state_actions = get_state_actions(
admin.VersionAdmin.get_state_actions
)
Expand Down

0 comments on commit 7a3af1a

Please sign in to comment.