diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index 884c95b4..ec43d1a5 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -1,5 +1,7 @@ +from cms.models.pagemodel import Page from django.conf.urls import include, url from django.contrib import admin +from django.contrib.sites.models import Site from django.conf.urls.i18n import i18n_patterns from django.conf.urls.static import static 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 +REDIRECT_TO_CMS = False +if Page.objects.filter(site_id=Site.objects.get_current().id).count(): + REDIRECT_TO_CMS = True + urlpatterns += i18n_patterns( - url(r'^$', LandingView.as_view()), url(r'^admin/', include(admin.site.urls)), url(r'^datacenterlight/', include('datacenterlight.urls', namespace="datacenterlight")), @@ -46,19 +51,22 @@ urlpatterns += i18n_patterns( url(r'^membership/', include(membership_urls)), url(r'^digitalglarus/', include('digitalglarus.urls', 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/', include('ungleich.urls', namespace='ungleich')), url( r'^blog/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$', RedirectView.as_view(pattern_name='ungleich:post-detail')), - url(r'^blog/|cms/$', RedirectView.as_view( - url=reverse_lazy('ungleich:post-list')), name='blog_list_view'), + url(r'^blog/$', RedirectView.as_view( + url=reverse_lazy('ungleich:post-list') + ), name='blog_list_view' + ), 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 += [