Skip to content
Snippets Groups Projects
urls.py 2.08 KiB
Newer Older
Todd Dembrey's avatar
Todd Dembrey committed
from django.conf import settings
Todd Dembrey's avatar
Todd Dembrey committed
from django.urls import include, path
Todd Dembrey's avatar
Todd Dembrey committed
from django.contrib import admin
from django.views.generic import TemplateView
from django.conf.urls import url
Todd Dembrey's avatar
Todd Dembrey committed

from wagtail.contrib.sitemaps.views import sitemap
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls
from wagtail.images.views.serve import ServeView
Todd Dembrey's avatar
Todd Dembrey committed

Todd Dembrey's avatar
Todd Dembrey committed
from opentech.public import urls as public_urls
from opentech.apply.users.urls import public_urlpatterns as user_urls
Todd Dembrey's avatar
Todd Dembrey committed

urlpatterns = [
Todd Dembrey's avatar
Todd Dembrey committed
    path('django-admin/', admin.site.urls),
    path('admin/', include(wagtailadmin_urls)),

    path('documents/', include(wagtaildocs_urls)),
Todd Dembrey's avatar
Todd Dembrey committed
    path('sitemap.xml', sitemap),
    path('', include((user_urls, 'users_public'))),
Todd Dembrey's avatar
Todd Dembrey committed
    path('', include('social_django.urls', namespace='social')),
    path('tinymce/', include('tinymce.urls')),
    path('select2/', include('django_select2.urls')),
Todd Dembrey's avatar
Todd Dembrey committed
]


if settings.DEBUG:
    from django.conf.urls.static import static
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    # Serve static and media files from development server
    urlpatterns += staticfiles_urlpatterns()
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

    urlpatterns += [
        # Add views for testing 404 and 500 templates
Todd Dembrey's avatar
Todd Dembrey committed
        path('test404/', TemplateView.as_view(template_name='404.html')),
        path('test500/', TemplateView.as_view(template_name='500.html')),
Todd Dembrey's avatar
Todd Dembrey committed
    ]

if settings.DEBUG or settings.ENABLE_STYLEGUIDE:
    urlpatterns += [
        # Add styleguide
Todd Dembrey's avatar
Todd Dembrey committed
        path('styleguide/', TemplateView.as_view(template_name='styleguide.html')),
urlpatterns += [
    url(r'^images/([^/]*)/(\d*)/([^/]*)/[^/]*$', ServeView.as_view(), name='wagtailimages_serve'),
]

Todd Dembrey's avatar
Todd Dembrey committed
urlpatterns += [
Todd Dembrey's avatar
Todd Dembrey committed
    path('', include(wagtail_urls)),

if settings.DEBUG and settings.DEBUGTOOLBAR:
    import debug_toolbar
    urlpatterns = [
        path('__debug__/', include(debug_toolbar.urls)),
    ] + urlpatterns