mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2024-12-24 17:42:23 +00:00
Add view permission in REST API
This commit is contained in:
parent
6a79169496
commit
d6df704d09
16
med/permissions.py
Normal file
16
med/permissions.py
Normal file
@ -0,0 +1,16 @@
|
||||
from rest_framework.permissions import DjangoModelPermissions
|
||||
|
||||
|
||||
class DjangoViewModelPermissions(DjangoModelPermissions):
|
||||
"""
|
||||
Add view permission
|
||||
"""
|
||||
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'],
|
||||
}
|
@ -154,7 +154,7 @@ STATIC_URL = '/static/'
|
||||
# Django REST Framework
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.DjangoModelPermissions',
|
||||
'med.permissions.DjangoViewModelPermissions',
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user