blender-studio/studio/urls.py

85 lines
3.4 KiB
Python

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.flatpages import views
from django.urls import path, include, re_path
from django.views.generic import TemplateView
from rest_framework import routers
import blender_id_oauth_client.urls
import blog.urls
import comments.urls
import films.urls
import search.urls
import looper.urls
import subscriptions.urls
import training.urls
import static_assets.urls
import users.urls
import characters.urls
from common.views.api.markdown_preview import markdown_preview as markdown_preview_view
from common.views.home import home as home_view, welcome as welcome_view
import common.views.errors as error_views
import static_assets.viewsets
import training.viewsets
admin.site.site_header = settings.ADMIN_SITE_HEADER
admin.site.site_title = settings.ADMIN_SITE_TITLE
admin.site.enable_nav_sidebar = False
router = routers.DefaultRouter(trailing_slash=True)
router.register(r'static-asset', static_assets.viewsets.StaticAssetViewSet)
router.register(r'training/section', training.viewsets.SectionViewSet)
# To leverage the docs boilerplate, a view set is used for single endpoint here too.
router.register(r'upload', static_assets.viewsets.UploadViewSet, basename='upload')
router.get_api_root_view().cls.__name__ = "API"
router.get_api_root_view().cls.__doc__ = "Blender Studio API"
urlpatterns = [
path('admin/doc/', include('django.contrib.admindocs.urls')),
path('admin/', include('loginas.urls')),
path('admin/', admin.site.urls),
path('oauth/', include(blender_id_oauth_client.urls)),
path('', home_view, name='home'),
path('welcome/', welcome_view, name='welcome'),
path('comments/', include(comments.urls)),
path('films/', include(films.urls)),
path('training/', include(training.urls)),
path('blog/', include(blog.urls)),
path('api/markdown-preview', markdown_preview_view, name='api-markdown-preview'),
path('api/', include((router.urls, 'api'), namespace='api')),
path('', include(characters.urls)),
path('search/', include(search.urls)),
path('looper/', include((looper.urls), namespace='looper')),
path('', include((subscriptions.urls), namespace='subscriptions')),
path('', include(users.urls)),
path('', include(static_assets.urls)),
path('stats/', include('stats.urls')),
path('activity/', include('actstream.urls')),
re_path(r'^webhooks/', include('anymail.urls')),
path('_nested_admin/', include('nested_admin.urls')),
path('s3direct/', include('s3direct.urls')),
]
handler400 = error_views.ErrorView.as_view(template_name='common/errors/400.html', status=400)
handler403 = error_views.ErrorView.as_view(template_name='common/errors/403.html', status=403)
handler404 = error_views.ErrorView.as_view(template_name='common/errors/404.html', status=404)
handler500 = error_views.ErrorView.as_view(template_name='common/errors/500.html', status=500)
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# Test different error pages by changing the template (400.html, 403.html, etc.)
urlpatterns += [path('error', TemplateView.as_view(template_name='common/errors/404.html'))]
import debug_toolbar
urlpatterns = [path('__debug__/', include(debug_toolbar.urls))] + urlpatterns
# Flatpages catch-all
urlpatterns += [
re_path(r'^(?P<url>.*/)$', views.flatpage),
]