8000 fix: Remove workaround for page-specific rendering (#411) · django-cms/djangocms-versioning@1c8b14b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c8b14b

Browse files
authored
fix: Remove workaround for page-specific rendering (#411)
1 parent 34577f0 commit 1c8b14b

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

djangocms_versioning/plugin_rendering.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from functools import lru_cache
22

3+
from cms import __version__ as cms_version
34
from cms.plugin_rendering import ContentRenderer, StructureRenderer
45
from cms.utils.placeholder import rescan_placeholders_for_obj
56

@@ -41,29 +42,32 @@ def render_plugin(self, instance, context, placeholder=None, editable=False):
4142
prefetch_versioned_related_objects(instance, self.toolbar)
4243
return super().render_plugin(instance, context, placeholder, editable)
4344

44-
def render_obj_placeholder(
45-
self, slot, context, inherit, nodelist=None, editable=True
46-
):
47-
# FIXME This is an ad-hoc solution for page-specific rendering
48-
# code, which by default doesn't work well with versioning.
49-
# Remove this method once the issue is fixed.
50-
from cms.models import Placeholder
45+
if cms_version in ("4.1.0", "4.1.1"):
46+
# Only needed for CMS 4.1.0 and 4.1.1 which have fix #7952 not merged
47+
# With #7952, page-specific rendering works well with versioning.
48+
def render_obj_placeholder(
49+
self, slot, context, inherit, nodelist=None, editable=True
50+
):
51+
# FIXME This is an ad-hoc solution for page-specific rendering
52+
# code, which by default doesn't work well with versioning.
53+
# Remove this method once the issue is fixed.
54+
from cms.models import Placeholder
5155

52-
current_obj = self.toolbar.get_object()
56+
current_obj = self.toolbar.get_object()
5357

54-
# Not page, therefore we will use toolbar object as
55-
# the current object and render the placeholder
56-
rescan_placeholders_for_obj(current_obj)
57-
placeholder = Placeholder.objects.get_for_obj(current_obj).get(slot=slot)
58-
content = self.render_placeholder(
59-
placeholder,
60-
context=context,
61-
page=current_obj,
62-
editable=editable,
63-
use_cache=True,
64-
nodelist=None,
65-
)
66-
return content
58+
# Not page, therefore we will use toolbar object as
59+
# the current object and render the placeholder
60+
rescan_placeholders_for_obj(current_obj)
61+
placeholder = Placeholder.objects.get_for_obj(current_obj).get(slot=slot)
62+
content = self.render_placeholder(
63+
placeholder,
64+
context=context,
65+
page=current_obj,
66+
editable=editable,
67+
use_cache=True,
68+
nodelist=None,
69+
)
70+
return content
6771

6872

6973
class VersionStructureRenderer(StructureRenderer):

0 commit comments

Comments
 (0)
0