mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2025-06-30 07:11:09 +02:00
Add REST API
This commit is contained in:
@ -34,6 +34,7 @@ INSTALLED_APPS = [
|
||||
|
||||
# External apps
|
||||
'reversion',
|
||||
'rest_framework',
|
||||
|
||||
# Django contrib
|
||||
'django.contrib.admin',
|
||||
@ -150,6 +151,13 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
|
||||
# Example: "http://example.com/static/", "http://static.example.com/"
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# Django REST Framework
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.DjangoModelPermissions',
|
||||
]
|
||||
}
|
||||
|
||||
# Med configuration
|
||||
PAGINATION_NUMBER = 25
|
||||
|
||||
|
27
med/urls.py
27
med/urls.py
@ -2,21 +2,42 @@
|
||||
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.views import PasswordResetView
|
||||
from django.urls import include, path
|
||||
from django.views.generic import RedirectView
|
||||
from django.views.generic import RedirectView, TemplateView
|
||||
from rest_framework import routers
|
||||
from rest_framework.schemas import get_schema_view
|
||||
|
||||
from media.views import index
|
||||
import media.views
|
||||
import users.views
|
||||
from .admin import admin_site
|
||||
|
||||
# API router
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'authors', media.views.AuteurViewSet)
|
||||
router.register(r'media', media.views.MediaViewSet)
|
||||
router.register(r'borrowed_items', media.views.EmpruntViewSet)
|
||||
router.register(r'games', media.views.JeuViewSet)
|
||||
router.register(r'users', users.views.UserViewSet)
|
||||
router.register(r'groups', users.views.GroupViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
path('', index, name='index'),
|
||||
path('', media.views.index, name='index'),
|
||||
|
||||
# Include project routers
|
||||
path('users/', include('users.urls')),
|
||||
path('media/', include('media.urls')),
|
||||
path('logs/', include('logs.urls')),
|
||||
|
||||
# REST API
|
||||
path('api/', include(router.urls)),
|
||||
path('api-auth/', include('rest_framework.urls')),
|
||||
path('openapi', login_required(get_schema_view()), name='openapi-schema'),
|
||||
path('redoc/',
|
||||
login_required(TemplateView.as_view(template_name='redoc.html')),
|
||||
name='redoc'),
|
||||
|
||||
# Include Django Contrib and Core routers
|
||||
path('accounts/password_reset/', PasswordResetView.as_view(),
|
||||
name='admin_password_reset'),
|
||||
|
Reference in New Issue
Block a user