forked from ungleich-public/dynamicweb
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.
This commit is contained in:
parent
61af03b342
commit
292f3d0513
4 changed files with 14 additions and 17 deletions
|
|
@ -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')),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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, '<h1>{}</h1><p>{}</p>'.format(name, tagline))
|
||||
for slug, title, text in SUB_PAGES:
|
||||
child = create_page(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue