Merge pull request #600 from pcoder/task/4362/fix_need_of_cms_dummy_page

Task/4362/Remove conflicting cms/ urlconf
This commit is contained in:
Pcoder 2018-04-06 20:13:25 +02:00 committed by GitHub
commit dbc702ebcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,7 @@
from cms.models.pagemodel import Page
from django.conf.urls import include, url from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
from django.contrib.sites.models import Site
from django.conf.urls.i18n import i18n_patterns from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static from django.conf.urls.static import static
from django.views import i18n, static as static_view from django.views import i18n, static as static_view
@ -35,8 +37,11 @@ urlpatterns += i18n_patterns(
) )
# note the django CMS URLs included via 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
urlpatterns += i18n_patterns( urlpatterns += i18n_patterns(
url(r'^$', LandingView.as_view()),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^datacenterlight/', url(r'^datacenterlight/',
include('datacenterlight.urls', namespace="datacenterlight")), include('datacenterlight.urls', namespace="datacenterlight")),
@ -46,19 +51,22 @@ urlpatterns += i18n_patterns(
url(r'^membership/', include(membership_urls)), url(r'^membership/', include(membership_urls)),
url(r'^digitalglarus/', include('digitalglarus.urls', url(r'^digitalglarus/', include('digitalglarus.urls',
namespace="digitalglarus")), namespace="digitalglarus")),
# url(r'^blog/', include('ungleich.urls', namespace='ungleich')),
url(r'^',
include('ungleich_page.urls',
namespace='ungleich_page'),
name='ungleich_page'),
url(r'^cms/blog/', url(r'^cms/blog/',
include('ungleich.urls', namespace='ungleich')), include('ungleich.urls', namespace='ungleich')),
url( url(
r'^blog/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$', r'^blog/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$',
RedirectView.as_view(pattern_name='ungleich:post-detail')), RedirectView.as_view(pattern_name='ungleich:post-detail')),
url(r'^blog/|cms/$', RedirectView.as_view( url(r'^blog/$', RedirectView.as_view(
url=reverse_lazy('ungleich:post-list')), name='blog_list_view'), url=reverse_lazy('ungleich:post-list')
), name='blog_list_view'
),
url(r'^cms/', include('cms.urls')), url(r'^cms/', include('cms.urls')),
url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS
else LandingView.as_view()),
url(r'^',
include('ungleich_page.urls',
namespace='ungleich_page'),
name='ungleich_page'),
) )
urlpatterns += [ urlpatterns += [