8000 feat: django 5 support for cms 3.11 by protoroto · Pull Request #7724 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

feat: django 5 support for cms 3.11 #7724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix toolbar tests
  • Loading branch information
protoroto authored and marksweb committed Dec 21, 2023
commit 60f39ee6e338c8767d9a0de5f6ea85a0a1bd412e
3 changes: 2 additions & 1 deletion cms/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from cms.toolbar_pool import toolbar_pool
from cms.utils import get_language_from_request, page_permissions
from cms.utils.conf import get_cms_setting
from cms.utils.compat import DJANGO_5_0
from cms.utils.i18n import get_language_dict, get_language_tuple
from cms.utils.page_permissions import user_can_change_page, user_can_delete_page, user_can_publish_page
from cms.utils.urlutils import add_url_parameters, admin_reverse
Expand Down Expand Up @@ -225,7 +226,7 @@ def add_logout_button(self, parent):
action=admin_reverse('logout'),
active=True,
on_success=on_success,
method='GET',
method='GET' if not DJANGO_5_0 else 'POST',
)

def add_language_menu(self):
Expand Down
4 changes: 4 additions & 0 deletions cms/models/pluginmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def __new__(cls, name, bases, attrs):
# if there is a RenderMeta in attrs, use this one
# else try to use the one from the superclass (if present)
meta = attr_meta or getattr(new_class, '_render_meta', None)
treebeard_view_fields = (f for f in new_class._meta.fields
if f.name in ('depth', 'numchild', 'path'))
for field in treebeard_view_fields:
field.editable = False
# set a new BoundRenderMeta to prevent leaking of state
new_class._render_meta = BoundRenderMeta(meta)
return new_class
Expand Down
2 changes: 1 addition & 1 deletion cms/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ViewRestrictionInlineAdminForm,
)
from cms.api import assign_user_to_page, create_page, create_title
from cms.forms.fields import PageSelectFormField, SuperLazyIterator
from cms.forms.fields import LazyChoiceField, PageSelectFormField, SuperLazyIterator
from cms.forms.utils import get_page_choices, get_site_choices, update_site_and_page_choices
from cms.forms.widgets import ApplicationConfigSelect
from cms.models import ACCESS_PAGE, ACCESS_PAGE_AND_CHILDREN
Expand Down
7 changes: 5 additions & 2 deletions cms/tests/test_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from cms.toolbar.items import AjaxItem, Break, ItemSearchResult, LinkItem, SubMenu, ToolbarAPIMixin
from cms.toolbar.toolbar import CMSToolbar
from cms.toolbar_pool import toolbar_pool
from cms.utils.compat import DJANGO_4_2
from cms.utils.compat import DJANGO_4_2, DJANGO_5_0
from cms.utils.conf import get_cms_setting
from cms.utils.i18n import get_language_tuple
from cms.utils.urlutils import admin_reverse
Expand Down Expand Up @@ -641,7 +641,10 @@ def test_hide_toolbar_login_nonstaff(self):
def test_admin_logout_staff(self):
with override_settings(CMS_PERMISSION=True):
with self.login_user_context(self.get_staff()):
response = self.client.get('/en/admin/logout/')
if DJANGO_5_0:
response = self.client.post('/en/admin/logout/')
else:
response = self.client.get('/en/admin/logout/')
self.assertEqual(response.status_code, 200)

def test_show_toolbar_without_edit(self):
Expand Down
1 change: 1 addition & 0 deletions cms/utils/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
DJANGO_3 = Version(DJANGO_VERSION) < Version('4.0')
DJANGO_4_1 = Version(DJANGO_VERSION) < Version('4.2')
DJANGO_4_2 = Version(DJANGO_VERSION) < Version('4.3')
DJANGO_5_0 = Version(DJANGO_VERSION) < Version('5.1')
0