Skip to content

Commit

Permalink
fix: Avoid duplication of placeholder checks for locked versions (#393)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
fsbraun and jrief authored Mar 28, 2024
1 parent f43c923 commit b2d46f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 4 additions & 1 deletion djangocms_versioning/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ def ready(self):
from cms.models import contentmodels, fields
from cms.signals import post_obj_operation, post_placeholder_operation

from .conf import LOCK_VERSIONS
from .handlers import (
update_modified_date,
update_modified_date_for_pagecontent,
update_modified_date_for_placeholder_source,
)
from .helpers import is_content_editable
from .helpers import is_content_editable, placeholder_content_is_unlocked_for_user

# Add check to PlaceholderRelationField
fields.PlaceholderRelationField.default_checks += [is_content_editable]
if LOCK_VERSIONS:
fields.PlaceholderRelationField.default_checks += [placeholder_content_is_unlocked_for_user]

# Remove uniqueness constraint from PageContent model to allow for different versions
pagecontent_unique_together = tuple(
Expand Down
9 changes: 0 additions & 9 deletions djangocms_versioning/cms_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@

from . import indicators, versionables
from .admin import VersioningAdminMixin
from .conf import LOCK_VERSIONS
from .constants import INDICATOR_DESCRIPTIONS
from .datastructures import BaseVersionableItem, VersionableItem
from .exceptions import ConditionFailed
from .helpers import (
get_latest_admin_viewable_content,
inject_generic_relation_to_version,
is_editable,
placeholder_content_is_unlocked_for_user,
register_versionadmin_proxy,
replace_admin_for_models,
replace_manager,
Expand Down Expand Up @@ -160,12 +158,6 @@ def handle_admin_field_modifiers(self, cms_config):
for key in modifier.keys():
self.add_to_field_extension[key] = modifier[key]

def handle_locking(self):
if LOCK_VERSIONS:
from cms.models import fields

fields.PlaceholderRelationField.default_checks += [placeholder_content_is_unlocked_for_user]

def configure_app(self, cms_config):
if hasattr(cms_config, "extended_admin_field_modifiers"):
self.handle_admin_field_modifiers(cms_config)
Expand All @@ -188,7 +180,6 @@ def configure_app(self, cms_config):
self.handle_version_admin(cms_config)
self.handle_content_model_generic_relation(cms_config)
self.handle_content_model_manager(cms_config)
self.handle_locking()


def copy_page_content(original_content):
Expand Down

0 comments on commit b2d46f6

Please sign in to comment.