diff --git a/djangocms_version_locking/cms_config.py b/djangocms_version_locking/cms_config.py index a3bee3b..e26f065 100644 --- a/djangocms_version_locking/cms_config.py +++ b/djangocms_version_locking/cms_config.py @@ -21,12 +21,6 @@ def add_alias_version_lock(obj, field): class VersionLockingCMSExtension(CMSAppExtension): - def __init__(self): - # The monkey patch is here to be sure that at module load time the Version class - # is registered and can be overriden without requiring a strict load order - # in the INSTALLED_APPS setting in a projects settings.py. This is why this patch - # Isn't loaded from: VersionLockingConfig.ready - from .monkeypatch import admin as monkeypatch_admin # noqa: F401 def configure_app(self, cms_config): pass diff --git a/djangocms_version_locking/monkeypatch/admin.py b/djangocms_version_locking/monkeypatch/admin.py deleted file mode 100644 index 9060e86..0000000 --- a/djangocms_version_locking/monkeypatch/admin.py +++ /dev/null @@ -1,22 +0,0 @@ -from django.template.loader import render_to_string - -from djangocms_versioning import admin, constants -from djangocms_versioning.helpers import version_is_locked - - -def _locked(self, version): - """ - Generate an locked field for Versioning Admin, to override the default locked icon from djangocms-versioning. - """ - if version.state == constants.DRAFT and version_is_locked(version): - return render_to_string('djangocms_version_locking/admin/locked_icon.html') - return "" - - -admin.VersionAdmin.locked = _locked - - -# Add Version Locking css media to the Versioning Admin instance -additional_css = ('djangocms_version_locking/css/version-locking.css',) -# admin.VersionAdmin.Media.css['all'] = admin.VersionAdmin.Media.css['all'] + additional_css -setattr(admin.VersionAdmin.Media, 'css', {"all": ('djangocms_version_locking/css/version-locking.css',)}) diff --git a/tests/test_admin_monkeypatch.py b/tests/test_admin_monkeypatch.py deleted file mode 100644 index d8f53a8..0000000 --- a/tests/test_admin_monkeypatch.py +++ /dev/null @@ -1,51 +0,0 @@ -from cms.test_utils.testcases import CMSTestCase - -from djangocms_versioning.helpers import version_list_url - -from djangocms_version_locking.test_utils import factories - - -class VersionLockedIconTestCase(CMSTestCase): - - @classmethod - def setUpTestData(cls): - cls.default_permissions = ["change_pollcontentversion"] - - def setUp(self): - self.superuser = self.get_superuser() - self.regular_user = self._create_user( - "regular", - is_staff=True, - permissions=["view_pollcontentversion"] + self.default_permissions, - ) - - def test_version_locked_icon_added(self): - """ - With the admin monkeypatch, the locked icon template is override - """ - poll_version = factories.PollVersionFactory(created_by=self.superuser) - changelist_url = version_list_url(poll_version.content) - - with self.login_user_context(self.regular_user): - response = self.client.post(changelist_url) - self.assertContains(response, '') - self.assertContains(response, '') - - -class VersionLockMediaMonkeyPatchTestCase(CMSTestCase): - - def setUp(self): - self.superuser = self.get_superuser() - - def test_version_locking_css_media_loaded(self): - """ - The verison locking css media is loaded on the page - """ - poll_version = factories.PollVersionFactory(created_by=self.superuser) - changelist_url = version_list_url(poll_version.content) - css_file = "djangocms_version_locking/css/version-locking.css" - - with self.login_user_context(self.superuser): - response = self.client.post(changelist_url) - - self.assertContains(response, css_file)