Skip to content

Commit b2d46f6

Browse files
fsbraunjrief
andauthored
fix: Avoid duplication of placeholder checks for locked versions (#393)
* fix #384: Unlock button in toolbar points onto DRAFT version * fix: placeholder checks only need added once * fix linting --------- Co-authored-by: Jacob Rief <[email protected]>
1 parent f43c923 commit b2d46f6

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

djangocms_versioning/apps.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ def ready(self):
1212
from cms.models import contentmodels, fields
1313
from cms.signals import post_obj_operation, post_placeholder_operation
1414

15+
from .conf import LOCK_VERSIONS
1516
from .handlers import (
1617
update_modified_date,
1718
update_modified_date_for_pagecontent,
1819
update_modified_date_for_placeholder_source,
1920
)
20-
from .helpers import is_content_editable
21+
from .helpers import is_content_editable, placeholder_content_is_unlocked_for_user
2122

2223
# Add check to PlaceholderRelationField
2324
fields.PlaceholderRelationField.default_checks += [is_content_editable]
25+
if LOCK_VERSIONS:
26+
fields.PlaceholderRelationField.default_checks += [placeholder_content_is_unlocked_for_user]
2427

2528
# Remove uniqueness constraint from PageContent model to allow for different versions
2629
pagecontent_unique_together = tuple(

djangocms_versioning/cms_config.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@
2525

2626
from . import indicators, versionables
2727
from .admin import VersioningAdminMixin
28-
from .conf import LOCK_VERSIONS
2928
from .constants import INDICATOR_DESCRIPTIONS
3029
from .datastructures import BaseVersionableItem, VersionableItem
3130
from .exceptions import ConditionFailed
3231
from .helpers import (
3332
get_latest_admin_viewable_content,
3433
inject_generic_relation_to_version,
3534
is_editable,
36-
placeholder_content_is_unlocked_for_user,
3735
register_versionadmin_proxy,
3836
replace_admin_for_models,
3937
replace_manager,
@@ -160,12 +158,6 @@ def handle_admin_field_modifiers(self, cms_config):
160158
for key in modifier.keys():
161159
self.add_to_field_extension[key] = modifier[key]
162160

163-
def handle_locking(self):
164-
if LOCK_VERSIONS:
165-
from cms.models import fields
166-
167-
fields.PlaceholderRelationField.default_checks += [placeholder_content_is_unlocked_for_user]
168-
169161
def configure_app(self, cms_config):
170162
if hasattr(cms_config, "extended_admin_field_modifiers"):
171163
self.handle_admin_field_modifiers(cms_config)
@@ -188,7 +180,6 @@ def configure_app(self, cms_config):
188180
self.handle_version_admin(cms_config)
189181
self.handle_content_model_generic_relation(cms_config)
190182
self.handle_content_model_manager(cms_config)
191-
self.handle_locking()
192183

193184

194185
def copy_page_content(original_content):

0 commit comments

Comments
 (0)