Ajout et début de l'API REST
This commit is contained in:
11
Reskreen/rest_permission.py
Normal file
11
Reskreen/rest_permission.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from rest_framework import permissions
|
||||
class CustomPermission_DjangoModel_based(permissions.DjangoModelPermissions):
|
||||
perms_map = {
|
||||
'GET': ['%(app_label)s.view_%(model_name)s'],
|
||||
'OPTIONS': ['%(app_label)s.view_%(model_name)s'],
|
||||
'HEAD': ['%(app_label)s.view_%(model_name)s'],
|
||||
'POST': ['%(app_label)s.add_%(model_name)s'],
|
||||
'PUT': ['%(app_label)s.change_%(model_name)s'],
|
||||
'PATCH': ['%(app_label)s.change_%(model_name)s'],
|
||||
'DELETE': ['%(app_label)s.delete_%(model_name)s'],
|
||||
}
|
@@ -55,6 +55,18 @@ INSTALLED_APPS = [
|
||||
'django_summernote',
|
||||
]
|
||||
|
||||
INSTALLED_APPS += ( 'apilog.apps.ApilogConfig',)
|
||||
|
||||
#Ajout de rest_framework
|
||||
INSTALLED_APPS += ('rest_framework', 'rest_framework.authtoken',)
|
||||
'''REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||
'rest_framework.authentication.TokenAuthentication', #Todo prod: replace by TokenAuthentication
|
||||
),
|
||||
# Autres paramètres de configuration...
|
||||
}'''
|
||||
|
||||
|
||||
LANGUAGE_CODE = 'fr-CH'
|
||||
|
||||
if not cfg_dev_mode:
|
||||
@@ -117,6 +129,8 @@ MIDDLEWARE = [
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
]
|
||||
|
||||
MIDDLEWARE += ('apilog.middleware.APILogMiddleware',)
|
||||
|
||||
ROOT_URLCONF = 'Reskreen.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
|
@@ -26,12 +26,15 @@ urlpatterns = [
|
||||
path('accounts/', admin.site.urls),
|
||||
path('collabs/', include('collabs.urls')),
|
||||
path('vehicules/', include('vehicles.urls')),
|
||||
path('comm-opmessage/', include('comm_op.urls')),
|
||||
path('caldav/', include('mycaldav.urls')),
|
||||
#path('collabs_hour/', include('collabs.urls')),
|
||||
path('carnet_rouge/', include('carnet_rouge.urls')),
|
||||
path('student_eval/', include('studenteval.urls')),
|
||||
path('summernote/', include('django_summernote.urls')),
|
||||
path('editor/', include('django_summernote.urls')),
|
||||
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
||||
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
|
Reference in New Issue
Block a user