mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 17:06:09 +00:00
DEBUG was fixed to False in the template, and Docker builds settings.py from it in each container: debug mode could only be had by editing the file inside a running container. It is now read from the environment like the other options; off unless the variable is 1. The toolbar's URLs follow settings-dev, which installs the toolbar, not DEBUG: with the dev packages present, DEBUG alone imported them without the app and every URL lookup failed.
51 lines
2 KiB
Python
51 lines
2 KiB
Python
from django.conf import settings
|
|
from django.urls import include, path, re_path
|
|
from drf_spectacular.views import (
|
|
SpectacularAPIView,
|
|
SpectacularRedocView,
|
|
SpectacularSwaggerSplitView,
|
|
)
|
|
from drf_spectacular.utils import extend_schema
|
|
from rest_framework.decorators import api_view
|
|
from rest_framework.exceptions import NotFound
|
|
|
|
from appsettings.views import appsettings
|
|
from console.views import console
|
|
from instances.views import index
|
|
|
|
|
|
@extend_schema(exclude=True)
|
|
@api_view(["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"])
|
|
def api_not_found(request):
|
|
"""An API URL that names nothing: JSON, after the API's authentication, as
|
|
every other API answer. Only one with a trailing slash: one without is
|
|
redirected to it first."""
|
|
raise NotFound
|
|
|
|
|
|
urlpatterns = [
|
|
path("", index, name="index"),
|
|
path("admin/", include(("admin.urls", "admin"), namespace="admin")),
|
|
path("accounts/", include("accounts.urls")),
|
|
path("appsettings/", appsettings, name="appsettings"),
|
|
path("computes/", include("computes.urls")),
|
|
path("console/<int:compute_id>/<str:uuid>/", console, name="console"),
|
|
path("datasource/", include("datasource.urls")),
|
|
path("instances/", include("instances.urls")),
|
|
path("i18n/", include("django.conf.urls.i18n")),
|
|
path("logs/", include("logs.urls")),
|
|
path("jobs/", include("operations.urls")),
|
|
path('api/v1/', include("webvirtcloud.urls-api")),
|
|
path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
|
|
re_path(r"^swagger\.(?P<format>json|yaml)$", SpectacularAPIView.as_view(), name="schema-json"),
|
|
path("swagger/", SpectacularSwaggerSplitView.as_view(url_name="schema"), name="schema-swagger-ui"),
|
|
path("redoc/", SpectacularRedocView.as_view(url_name="schema"), name="schema-redoc"),
|
|
re_path(r"^api/(?:.*/)?$", api_not_found),
|
|
]
|
|
|
|
# settings-dev installs the toolbar; WEBVIRTCLOUD_DEBUG alone does not
|
|
if "debug_toolbar" in settings.INSTALLED_APPS:
|
|
import debug_toolbar
|
|
|
|
urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]
|
|
|