8000 fix: Remove deprecated `get_storage_class` import from `cms.utils` (#… · django-cms/django-cms@31f80c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31f80c5

Browse files
authored
fix: Remove deprecated get_storage_class import from cms.utils (#8102)
* fix: Move `get_storage_class` to lazy object * Create test requirement for django-5.1.txt * Update test.yml * fix: Replace get_storage_class by import_string * Update setup.cfg to pin Django to <5.2 * Run tests with Postgres 13 * Update trove classifiers * Add output_field to Concat
1 parent ceb274c commit 31f80c5

File tree

6 files changed

+30
-10
lines changed

6 files changed

+30
-10
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jobs:
1818
django-4.0.txt,
1919
django-4.1.txt,
2020
django-4.2.txt,
21-
django-5.0.txt
21+
django-5.0.txt,
22+
django-5.1.txt
2223
]
2324
os: [
2425
ubuntu-20.04,
@@ -28,10 +29,14 @@ jobs:
2829
python-version: 3.8
2930
- requirements-file: django-5.0.txt
3031
python-version: 3.9
32+
- requirements-file: django-5.1.txt
33+
python-version: 3.8
34+
- requirements-file: django-5.1.txt
35+
python-version: 3.9
3136

3237
services:
3338
postgres:
34-
image: postgres:12
39+
image: postgres:13
3540
env:
3641
POSTGRES_USER: postgres
3742
POSTGRES_PASSWORD: postgres
@@ -76,7 +81,8 @@ jobs:
7681
django-4.0.txt,
7782
django-4.1.txt,
7883
django-4.2.txt,
79-
django-5.0.txt
84+
django-5.0.txt,
85+
django-5.1.txt
8086
]
8187
os: [
8288
ubuntu-20.04,
@@ -86,6 +92,10 @@ jobs:
8692
python-version: 3.8
8793
- requirements-file: django-5.0.txt
8894
python-version: 3.9
95+
- requirements-file: django-5.1.txt
96+
python-version: 3.8
97+
- requirements-file: django-5.1.txt
98+
python-version: 3.9
8999

90100
services:
91101
mysql:
@@ -134,7 +144,8 @@ jobs:
134144
django-4.0.txt,
135145
django-4.1.txt,
136146
django-4.2.txt,
137-
django-5.0.txt
147+
django-5.0.txt,
148+
django-5.1.txt
138149
]
139150
os: [
140151
ubuntu-20.04,
@@ -144,6 +155,10 @@ jobs:
144155
python-version: 3.8
145156
- requirements-file: django-5.0.txt
146157
python-version: 3.9
158+
- requirements-file: django-5.1.txt
159+
python-version: 3.8
160+
- requirements-file: django-5.1.txt
161+
python-version: 3.9
147162

148163
steps:
149164
- uses: actions/checkout@v3

cms/models/pagemodel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def _update_title_path_recursive(self, language, slug=None):
360360
base = self.get_path(language, fallback=True)
361361

362362
if base:
363-
new_path = Concat(models.Value(base), models.Value('/'), models.F('slug'))
363+
new_path = Concat(models.Value(base), models.Value('/'), models.F('slug'), output_field=models.CharField())
364364
else:
365365
# User is moving the homepage
366366
new_path = models.F('slug')
@@ -386,7 +386,7 @@ def _set_title_root_path(self):
386386
# to include this page's slug as its path prefix
387387
(translations
388388
.filter(language=language)
389-
.update(path=Concat(models.Value(slug), models.Value('/'), 'path')))
389+
.update(path=Concat(models.Value(slug), models.Value('/'), 'path', output_field=models.CharField())))
390390

391391
# Explicitly update this page's path to match its slug
392392
# Doing this is cheaper than a TRIM call to remove the "/" characters
@@ -1190,7 +1190,7 @@ def mark_descendants_as_published(self, language):
11901190
)
11911191

11921192
if base:
1193-
new_path = Concat(models.Value(base), models.Value('/'), models.F('slug'))
1193+
new_path = Concat(models.Value(base), models.Value('/'), models.F('slug'), output_field=models.CharField())
11941194
else:
11951195
# User is moving the homepage
11961196
new_path = models.F('slug')

cms/utils/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# TODO: this is just stuff from utils.py - should be split / moved
22
from django.conf import settings
3-
from django.core.files.storage import get_storage_class
43
from django.utils.functional import LazyObject
54

65
from cms.utils.conf import get_site_id # nopyflakes
@@ -54,7 +53,9 @@ def get_language_from_request(request, current_page=None):
5453

5554
class ConfiguredStorage(LazyObject):
5655
def _setup(self):
57-
self._wrapped = get_storage_class(getattr(settings, 'STATICFILES_STORAGE', default_storage))()
56+
from django.utils.module_loading import import_string
57+
58+
self._wrapped = import_string(getattr(settings, 'STATICFILES_STORAGE', default_storage))()
5859

5960

6061
configured_storage = ConfiguredStorage()

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ skip = package-lock.json,*.js,*.po,./node_modules/*,./.idea/*,./docs/env/*,./doc
2626

2727
[options]
2828
install_requires =
29-
Django>=3.2
29+
Django>=3.2,<5.2
3030
python_requires = >=3.7
3131

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
'Programming Language :: Python :: 3.9',
2929
'Programming Language :: Python :: 3.10',
3030
'Programming Language :: Python :: 3.11',
31+
'Programming Language :: Python :: 3.12',
3132
'Framework :: Django',
3233
'Framework :: Django :: 2.2',
3334
'Framework :: Django :: 3.1',
@@ -36,6 +37,7 @@
3637
'Framework :: Django :: 4.1',
3738
'Framework :: Django :: 4.2',
3839
'Framework :: Django :: 5.0',
40+
'Framework :: Django :: 5.1',
3941
'Topic :: Internet :: WWW/HTTP',
4042
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
4143
'Topic :: Software Development',

test_requirements/django-5.1.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-r requirements_base.txt
2+
Django>=5.1,<5.2

0 commit comments

Comments
 (0)
0