Skip to content

Commit fa74e84

Browse files
authored
Merge pull request #191 from FlipperPA/upgrade/django-4-and-wagtail-2.16
Django 4.0 and Wagtail 2.16 Upgrade
2 parents 0777192 + 5a8c4d9 commit fa74e84

22 files changed

+462
-259
lines changed

example/urls.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.conf import settings
22
from django.conf.urls.static import static
3-
from django.conf.urls import include, url
3+
from django.urls import include, re_path
44
from django.contrib import admin
55

66
from wagtail.admin import urls as wagtailadmin_urls
@@ -9,14 +9,14 @@
99

1010

1111
urlpatterns = [
12-
url(r'^admin/', admin.site.urls),
13-
url(r'^cms/', include(wagtailadmin_urls)),
14-
url(r'^documents/', include(wagtaildocs_urls)),
12+
re_path(r'^admin/', admin.site.urls),
13+
re_path(r'^cms/', include(wagtailadmin_urls)),
14+
re_path(r'^documents/', include(wagtaildocs_urls)),
1515
]
1616

1717
if settings.DEBUG: # pragma: no cover
1818
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
1919

2020
urlpatterns += [
21-
url(r'', include(wagtail_urls)),
21+
re_path(r'', include(wagtail_urls)),
2222
]

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@
6060
"Framework :: Wagtail",
6161
"Framework :: Wagtail :: 2",
6262
"Programming Language :: Python :: 3",
63-
"Programming Language :: Python :: 3.6",
6463
"Programming Language :: Python :: 3.7",
6564
"Programming Language :: Python :: 3.8",
65+
"Programming Language :: Python :: 3.9",
66+
"Programming Language :: Python :: 3.10",
6667
"Framework :: Django",
67-
"Framework :: Django :: 2.0",
68-
"Framework :: Django :: 3.0",
68+
"Framework :: Django :: 2.2",
69+
"Framework :: Django :: 3.2",
70+
"Framework :: Django :: 4",
6971
"Framework :: Wagtail",
7072
"Framework :: Wagtail :: 2",
7173
"Topic :: Internet :: WWW/HTTP :: Site Management",

tests/blocks/test_form_block.py

Lines changed: 202 additions & 99 deletions
Large diffs are not rendered by default.

tests/models/test_form.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.core.exceptions import ValidationError
22
from django.db import models
33
from django.test import override_settings
4-
from django.utils.translation import ugettext_lazy as _
4+
from django.utils.translation import gettext_lazy as _
55
from wagtail.core.models import Page
66

77
from wagtailstreamforms.conf import get_setting

tests/settings.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,14 @@
4343
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
4444
]
4545

46-
WAGTAIL_VERSION = re.search("wt[0-9]*", os.environ.get("TOX_ENV_NAME", "wt211"))[0]
46+
DJANGO_VERSION = int(
47+
re.search("dj([0-9]+)", os.environ.get("TOX_ENV_NAME", "dj40")).group(1)
48+
)
49+
WAGTAIL_VERSION = int(
50+
re.search("wt([0-9]+)", os.environ.get("TOX_ENV_NAME", "wt216")).group(1)
51+
)
4752

48-
PRE_WAGTAIL_211_VERSIONS = [
49-
"wt23",
50-
"wt24",
51-
"wt25",
52-
"wt26",
53-
"wt27",
54-
"wt28",
55-
"wt29",
56-
"wt210",
57-
]
58-
59-
PRE_WAGTAIL_211 = False
60-
61-
if WAGTAIL_VERSION in PRE_WAGTAIL_211_VERSIONS:
62-
MIDDLEWARE.append("wagtail.core.middleware.SiteMiddleware")
63-
PRE_WAGTAIL_211 = True
53+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
6454

6555
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "testdb"}}
6656

tests/templatetags/test_form.py

Lines changed: 204 additions & 99 deletions
Large diffs are not rendered by default.

tests/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from django.conf.urls import include, url
1+
from django.urls import include, re_path
22
from django.contrib import admin
33
from wagtail.admin import urls as wagtailadmin_urls
44
from wagtail.core import urls as wagtail_urls
55

66
urlpatterns = [
7-
url(r"^admin/", admin.site.urls),
8-
url(r"^cms/", include(wagtailadmin_urls)),
9-
url(r"", include(wagtail_urls)),
7+
re_path(r"^admin/", admin.site.urls),
8+
re_path(r"^cms/", include(wagtailadmin_urls)),
9+
re_path(r"", include(wagtail_urls)),
1010
]

tests/views/test_copy.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,8 @@ def test_user_with_no_perm_no_access(self):
8080
self.client.login(username="user", password="password")
8181

8282
response = self.client.get(self.copy_url)
83-
if settings.PRE_WAGTAIL_211:
84-
self.assertEqual(response.status_code, 403)
85-
else:
86-
self.assertEqual(response.status_code, 302)
87-
self.assertTrue(response.url.startswith("/cms/"))
83+
self.assertEqual(response.status_code, 302)
84+
self.assertTrue(response.url.startswith("/cms/"))
8885

8986
def test_user_with_add_perm_has_access(self):
9087
access_admin = Permission.objects.get(codename="access_admin")

tests/views/test_delete.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django.conf import settings
21
from django.contrib.auth.models import Permission, User
32
from django.urls import reverse
43

@@ -34,7 +33,7 @@ def setUp(self):
3433

3534
self.client.login(username="user", password="password")
3635

37-
def test_get_responds(self):
36+
def test_get_response(self):
3837
response = self.client.get(self.multiple_url)
3938
self.assertEqual(response.status_code, 200)
4039

@@ -102,11 +101,8 @@ def test_user_with_no_perm_no_access(self):
102101
self.client.login(username="user", password="password")
103102

104103
response = self.client.get(self.delete_url)
105-
if settings.PRE_WAGTAIL_211:
106-
self.assertEqual(response.status_code, 403)
107-
else:
108-
self.assertEqual(response.status_code, 302)
109-
self.assertTrue(response.url.startswith("/cms/"))
104+
self.assertEqual(response.status_code, 302)
105+
self.assertTrue(response.url.startswith("/cms/"))
110106

111107
def test_user_with_delete_perm_has_access(self):
112108
access_admin = Permission.objects.get(codename="access_admin")

tests/views/test_submission_list.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,8 @@ def test_user_with_no_perm_no_access(self):
9696
self.client.login(username="user", password="password")
9797

9898
response = self.client.get(self.list_url)
99-
if settings.PRE_WAGTAIL_211:
100-
self.assertEqual(response.status_code, 403)
101-
else:
102-
self.assertEqual(response.status_code, 302)
103-
self.assertTrue(response.url.startswith("/cms/"))
99+
self.assertEqual(response.status_code, 302)
100+
self.assertTrue(response.url.startswith("/cms/"))
104101

105102
def test_user_with_add_perm_has_access(self):
106103
access_admin = Permission.objects.get(codename="access_admin")

0 commit comments

Comments
 (0)