From 292f3d05137e519191863fdcfdd3736acde6b05b Mon Sep 17 00:00:00 2001 From: Sajeyks Date: Tue, 6 Oct 2026 01:10:06 +0300 Subject: [PATCH] Adapt code to django CMS 3.6 and Django 1.11 Decide the home redirect per request instead of querying at import time, replace the removed _get_placeholder helper, stop shadowing the is_superuser field, and set the seeded home page as the CMS home. --- dynamicweb/urls.py | 14 +++++++++----- membership/models.py | 3 --- ungleich_page/cms_menus.py | 10 ++-------- utils/management/commands/seed_dummy_data.py | 4 +++- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index 113a5cda..b9a02981 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -41,9 +41,14 @@ urlpatterns += i18n_patterns( ) # note the django CMS URLs included via i18n_patterns -REDIRECT_TO_CMS = False -if Page.objects.filter(site_id=Site.objects.get_current().id).count(): - REDIRECT_TO_CMS = True + + +def home_view(request, *args, **kwargs): + # decided per request so that importing the urlconf needs no database + if Page.objects.filter(node__site_id=Site.objects.get_current().id).exists(): + return RedirectView.as_view(url='/cms')(request, *args, **kwargs) + return LandingView.as_view()(request, *args, **kwargs) + urlpatterns += i18n_patterns( url(r'^admin/', include(admin.site.urls)), @@ -64,8 +69,7 @@ urlpatterns += i18n_patterns( url(r'^cms/', include('cms.urls')), url(r'^blog/', include('djangocms_blog.urls', namespace='djangocms_blog')), url(r'^webhooks/', webhook_views.handle_webhook), - url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS - else LandingView.as_view()), + url(r'^$', home_view), url(r'^', include('ungleich_page.urls', namespace='ungleich_page')), ) diff --git a/membership/models.py b/membership/models.py index 81054fb9..abf30467 100644 --- a/membership/models.py +++ b/membership/models.py @@ -202,9 +202,6 @@ class CustomUser(AbstractBaseUser, PermissionsMixin): def get_random_password(cls): return get_random_string(24) - def is_superuser(self): - return False - def get_full_name(self): # The user is identified by their email address return self.email diff --git a/ungleich_page/cms_menus.py b/ungleich_page/cms_menus.py index 4e17c352..25d43608 100644 --- a/ungleich_page/cms_menus.py +++ b/ungleich_page/cms_menus.py @@ -2,7 +2,6 @@ from menus.base import NavigationNode from menus.menu_pool import menu_pool from django.utils.translation import ugettext_lazy as _ from cms.menu_bases import CMSAttachMenu -from cms.templatetags.cms_tags import _get_placeholder from cms.utils.plugins import get_plugins @@ -15,9 +14,6 @@ class GlasfaserMenu(CMSAttachMenu): glasfaser_cms = 'ungleich_page/glasfaser_cms_page.html' if (request and request.current_page and request.current_page.get_template() == glasfaser_cms): - template_context = { - "request": request, - } placeholder_name_list = [ 'Top Section', 'Middle Section', 'Glasfaser Services', 'Glasfaser About', 'Contact Section' @@ -27,10 +23,8 @@ class GlasfaserMenu(CMSAttachMenu): 'UngelichTextSection', 'Service', 'About' ] for placeholder_name in placeholder_name_list: - placeholder = _get_placeholder( - request.current_page, request.current_page, - template_context, placeholder_name - ) + placeholder = request.current_page.get_placeholders().filter( + slot=placeholder_name).first() plugins = get_plugins( request, placeholder, request.current_page.get_template() ) diff --git a/utils/management/commands/seed_dummy_data.py b/utils/management/commands/seed_dummy_data.py index 8a8c562c..367f9cbc 100644 --- a/utils/management/commands/seed_dummy_data.py +++ b/utils/management/commands/seed_dummy_data.py @@ -137,7 +137,7 @@ class Command(BaseCommand): page.publish(LANGUAGE) def seed_page(self, site): - if Page.objects.filter(reverse_id=REVERSE_ID, site=site).exists(): + if Page.objects.filter(reverse_id=REVERSE_ID, node__site=site).exists(): return template = SITE_TEMPLATES.get(site.domain, TEMPLATE) name, tagline = SITE_TEXTS.get( @@ -146,6 +146,8 @@ class Command(BaseCommand): name, template, LANGUAGE, slug='home', meta_description=tagline, published=True, in_navigation=True, site=site, reverse_id=REVERSE_ID) + # django CMS >= 3.5 serves /cms/ from the page flagged as home + home.set_as_homepage() self.add_text(home, '

{}

{}

'.format(name, tagline)) for slug, title, text in SUB_PAGES: child = create_page(