Skip to content

Commit

Permalink
ci: Add deprecations for functions not available in cms v4 (#7458)
Browse files Browse the repository at this point in the history
* Add deprecations
* Update message
  • Loading branch information
fsbraun committed Jan 6, 2023
1 parent 6443da8 commit fdda2a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cms/models/pluginmodel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import json
import os
import warnings
Expand Down Expand Up @@ -310,6 +311,11 @@ def copy_plugin(self, target_placeholder, target_language, parent_cache, no_sign
then overwriting its ID at step 5, the ORM will copy the custom
fields for us.
"""

warnings.warn(f"{inspect.stack()[0][3]} is deprecated and will be removed in django CMS 4.1. "
f"From version 4 on, please use cms.utils.copy_plugins_to_placeholder instead.",
DeprecationWarning, stacklevel=2)

try:
plugin_instance, cls = self.get_plugin_instance()
except KeyError: # plugin type not found anymore
Expand Down
10 changes: 10 additions & 0 deletions cms/utils/moderator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import inspect
import warnings


def use_draft(request):
warnings.warn(f"{inspect.stack()[0][3]} is deprecated and will be removed in django CMS 4.1",
DeprecationWarning, stacklevel=2)
is_staff = (request.user.is_authenticated and request.user.is_staff)
return is_staff and not request.session.get('cms_preview')

Expand All @@ -9,6 +13,8 @@ def get_model_queryset(model, request=None):
"""Decision function used in frontend - says which model should be used.
Public models are used unless looking at preview or edit versions of the page.
"""
warnings.warn(f"{inspect.stack()[0][3]} is deprecated and will be removed in django CMS 4.1",
DeprecationWarning, stacklevel=2)
if request and use_draft(request):
return model.objects.drafts()
return model.objects.public()
Expand All @@ -17,10 +23,14 @@ def get_model_queryset(model, request=None):
def get_title_queryset(request=None):
from cms.models import Title

warnings.warn(f"{inspect.stack()[0][3]} is deprecated and will be removed in django CMS 4.1",
DeprecationWarning, stacklevel=2)
return Title.objects.all()


def get_cmsplugin_queryset(request=None):
from cms.models import CMSPlugin

warnings.warn(f"{inspect.stack()[0][3]} is deprecated and will be removed in django CMS 4.1",
DeprecationWarning, stacklevel=2)
return CMSPlugin.objects.all()

0 comments on commit fdda2a2

Please sign in to comment.