8000 fix: Port forward #7664 and #7657 (#7695) · django-cms/django-cms@20fac70 · GitHub
[go: up one dir, main page]

Skip to content

Commit 20fac70

Browse files
fsbraunWill-Hoeywfehr
authored
fix: Port forward #7664 and #7657 (#7695)
* fix: preserve `view_class` in decorated views (#7664) * Fix tests * Bugfix: avoid InvalidCacheKey (memcached) for key-length ~249 (fixes #7595) (#7657) * Remove docs test from test suite (since covered by separate github action) * Remove docs requirements from the django-main test * Add setuptools to requirements for python 3.12 * Add setuptools to requirements.txt * Fix: Test with current ckeditor * Undo unnecessary change * Fix tests for Django 5.1 * Fix: Missing output_field --------- Co-authored-by: Will Hoey <48737592+Will-Hoey@users.noreply.github.com> Co-authored-by: wfehr <24782511+wfehr@users.noreply.github.com>
1 parent 5b592b9 commit 20fac70

File tree

11 files changed

+30
-117
lines changed

11 files changed

+30
-117
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ jobs:
5757
pip install pytest
5858
pip install -r test_requirements/${{ matrix.requirements-file }}
5959
pip install -r test_requirements/databases.txt
60-
pip install -r docs/requirements.txt
6160
python setup.py install
6261
6362
- name: Test with django test runner
@@ -116,7 +115,6 @@ jobs:
116115
pip install pytest
117116
pip install -r test_requirements/${{ matrix.requirements-file }}
118117
pip install -r test_requirements/databases.txt
119-
pip install -r docs/requirements.txt
120118
python setup.py install
121119
122120
@@ -161,7 +159,6 @@ jobs:
161159
python -m pip install --upgrade pip
162160
pip install pytest
163161
pip install -r test_requirements/${{ matrix.requirements-file }}
164-
pip install -r docs/requirements.txt
165162
python setup.py install
166163
167164
- name: Test with django test runner
@@ -196,7 +193,6 @@ jobs:
196193
python -m pip install --upgrade pip
197194
pip install -r test_requirements/${{ matrix.requirements-file }}
198195
pip install pytest ${{ matrix.django-version }}
199-
pip install --upgrade setuptools
200196
python setup.py install
201197
202198
- name: Test with django test runner
@@ -246,7 +242,6 @@ jobs:
246242
pip install -r test_requirements/${{ matrix.requirements-file }}
247243
pip install pytest ${{ matrix.django-version }}
248244
pip install -r test_requirements/databases.txt
249-
pip install -r docs/requirements.txt
250245
python setup.py install
251246
252247
- name: Test with django test runner
@@ -297,7 +292,6 @@ jobs:
297292
pip install -r test_requirements/${{ matrix.requirements-file }}
298293
pip install pytest ${{ matrix.django-version }}
299294
pip install -r test_requirements/databases.txt
300-
pip install -r docs/requirements.txt
301295
python setup.py install
302296
303297
- name: Test with django test runner

cms/cache/placeholder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ def _get_placeholder_cache_version_key(placeholder, lang, site_id):
4141
lang=str(lang),
4242
site=site_id,
4343
)
44-
if len(key) > 250:
44+
# django itself adds "version" add the end of cache-keys, e.g. "<key>:1".
45+
# -> If `cache.set()` is for example called with `version=""`, it still adds
46+
# `:` at the end. So if we check the length for `> 250`, a length of 249
47+
# or even 250 ends up in an InvalidCacheKey-exception.
48+
# In order to avoid these errors, we hash the keys at a lower length to also
49+
# have a little buffer.
50+
if len(key) > 200:
4551
key = '{prefix}|{hash}&# 67F4 39;.format(
4652
prefix=prefix,
4753
hash=hashlib.sha1(key.encode('utf-8')).hexdigest(),

cms/models/pagemodel.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ def set_as_homepage(self, user=None):
281281

282282
def _get_path_sql_value(self, base_path=''):
283283
if base_path:
284-
new_path = Concat(models.Value(base_path), models.Value('/'), models.F('slug'))
284+
new_path = Concat(
285+
models.Value(base_path),
286+
models.Value('/'),
287+
models.F('slug'),
288+
output_field=models.CharField(),
289+
)
285290
elif base_path is None:
286291
new_path = None
287292
else:

cms/test_utils/testcases.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
)
3131
from cms.plugin_rendering import ContentRenderer, StructureRenderer
3232
from cms.test_utils.util.context_managers import UserLoginContext
33+
from cms.utils.compat import DJANGO_4_1
3334
from cms.utils.conf import get_cms_setting
3435
from cms.utils.permissions import set_current_user
3536
from cms.utils.urlutils import admin_reverse
@@ -664,4 +665,6 @@ class CMSTestCase(BaseCMSTestCase, testcases.TestCase):
664665

665666

666667
class TransactionCMSTestCase(CMSTestCase, testcases.TransactionTestCase):
667-
pass
668+
if DJANGO_4_1:
669+
def assertQuerySetEqual(self, *args, **kwargs):
670+
return self.assertQuerysetEqual(*args, **kwargs)

cms/tests/test_docs.py

Lines changed: 0 additions & 99 deletions
This file was deleted.

cms/tests/test_placeholder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ def test_sets_source_when_title_is_created(self):
880880

881881
# check for en
882882
page_content_en = self.get_page_title_obj(page)
883-
self.assertQuerysetEqual(
883+
self.assertQuerySetEqual(
884884
Placeholder.objects.get_for_obj(page_content_en),
885885
page_content_en.get_placeholders(),
886886
transform=lambda x: x,
@@ -889,7 +889,7 @@ def test_sets_source_when_title_is_created(self):
889889

890890
# check for another language = de
891891
page_content_de = create_page_content('de', 'test page de', page)
892-
self.assertQuerysetEqual(
892+
self.assertQuerySetEqual(
893893
Placeholder.objects.get_for_obj(page_content_de),
894894
page_content_de.get_placeholders(),
895895
transform=lambda x: x,
@@ -983,7 +983,7 @@ def test_placeholder_relation_field(self):
983983
with self.login_user_context(self.get_superuser()):
984984
self.client.get(get_object_edit_url(poll))
985985

986-
self.assertQuerysetEqual(
986+
self.assertQuerySetEqual(
987987
poll.placeholders.all(),
988988
Placeholder.objects.get_for_obj(poll),
989989
transform=lambda x: x,

cms/tests/test_rendering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def test_passed_plugin_context_processor(instance, placeholder, context):
317317
instance._inst = instance
318318

319319
context = PluginContext(
320-
{'original_context_var': 'original_context_var_ok'},
320+
{'original_context_var': 'original_context_var_ok', "request": None},
321321
instance,
322322
self.test_placeholders['main'], processors=(test_passed_plugin_context_processor,)
323323
)

cms/utils/compat/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
DJANGO_3_1 = Version(DJANGO_VERSION) < Version('3.2')
1313
DJANGO_3_2 = Version(DJANGO_VERSION) < Version('3.3')
1414
DJANGO_3 = Version(DJANGO_VERSION) < Version('4.0')
15+
DJANGO_4_1 = Version(DJANGO_VERSION) < Version('4.2')
1516
DJANGO_4_2 = Version(DJANGO_VERSION) < Version('4.3')

cms/utils/decorators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def inner(request, *args, **kwargs):
2020
return func(request, *args, **kwargs)
2121
inner.__module__ = func.__module__
2222
inner.__doc__ = func.__doc__
23+
if hasattr(func, "view_class"):
24+
inner.view_class = func.view_class
2325
if hasattr(func, '__name__'):
2426
inner.__name__ = func.__name__
2527
elif hasattr(func, '__class__'):

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'django-sekizai>=0.7',
1414
'djangocms-admin-style>=1.2',
1515
'packaging',
16+
'setuptools',
1617
]
1718

1819

test_requirements/requirements_base.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ django-formtools
77
django-sekizai>=0.7
88
django-treebeard>=4.3
99
djangocms-admin-style>=1.5
10-
docutils<0.18 # Fix for: https://github.yuuza.net/sphinx-doc/sphinx/issues/9727
10+
djangocms-text-ckeditor
1111
iptools
1212
mock>=2.0.0
1313
Pillow
14-
pyenchant==3.0.1
14+
pyenchant
1515
pyflakes>=2.1
1616
python-coveralls>2.5.0
17-
unittest-xml-reporting==1.11.0
18-
ruff==0.1.0
17+
unittest-xml-reporting
18+
ruff
19+
setuptools # Since python 3.12
1920

2021
# FIXME: - Remove when a django 3.0 compatible djangocms-text-ckeditor version is released
21-
https://github.com/Aiky30/djangocms-text-ckeditor/archive/feature/cms-40-django-30-support-.zip
2222
https://github.com/ojii/django-better-test/archive/8aa2407d097fe3789b74682f0e6bd7d15d449416.zip#egg=django-better-test
2323
https://github.com/ojii/django-app-manage/archive/65da18ef234a4e985710c2c0ec760023695b40fe.zip#egg=django-app-manage

0 commit comments

Comments
 (0)
0