Skip to content

Commit

Permalink
Fix toolbar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
protoroto committed Dec 20, 2023
1 parent 1df3a2e commit 993a3b6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
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 comments on commit 993a3b6

Please sign in to comment.