Merge pull request #724 from ae-utbm/ninja

Use django-ninja for the API
This commit is contained in:
thomas girod
2024-07-24 00:48:08 +02:00
committed by GitHub
60 changed files with 1455 additions and 1331 deletions

View File

@ -78,7 +78,7 @@ INSTALLED_APPS = (
"django.contrib.sites",
"honeypot",
"django_jinja",
"rest_framework",
"ninja_extra",
"ajax_select",
"haystack",
"captcha",
@ -89,7 +89,6 @@ INSTALLED_APPS = (
"counter",
"eboutic",
"launderette",
"api",
"rootplace",
"sas",
"com",
@ -474,8 +473,8 @@ SITH_PEDAGOGY_UV_RESULT_GRADE = [
]
SITH_LOG_OPERATION_TYPE = [
(("SELLING_DELETION"), _("Selling deletion")),
(("REFILLING_DELETION"), _("Refilling deletion")),
("SELLING_DELETION", _("Selling deletion")),
("REFILLING_DELETION", _("Refilling deletion")),
]
SITH_PEDAGOGY_UTBM_API = "https://extranet1.utbm.fr/gpedago/api/guide"

View File

@ -19,6 +19,7 @@ from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from django.views.i18n import JavaScriptCatalog
from ninja_extra import NinjaExtraAPI
js_info_dict = {"packages": ("sith",)}
@ -26,8 +27,12 @@ handler403 = "core.views.forbidden"
handler404 = "core.views.not_found"
handler500 = "core.views.internal_servor_error"
api = NinjaExtraAPI(version="0.2.0", urls_namespace="api")
api.auto_discover_controllers()
urlpatterns = [
path("", include(("core.urls", "core"), namespace="core")),
path("api/", api.urls),
path("rootplace/", include(("rootplace.urls", "rootplace"), namespace="rootplace")),
path(
"subscription/",
@ -47,7 +52,6 @@ urlpatterns = [
include(("launderette.urls", "launderette"), namespace="launderette"),
),
path("sas/", include(("sas.urls", "sas"), namespace="sas")),
path("api/v1/", include(("api.urls", "api"), namespace="api")),
path("election/", include(("election.urls", "election"), namespace="election")),
path("forum/", include(("forum.urls", "forum"), namespace="forum")),
path("galaxy/", include(("galaxy.urls", "galaxy"), namespace="galaxy")),
@ -61,7 +65,6 @@ urlpatterns = [
path("captcha/", include("captcha.urls")),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)