mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Monkey-patch DRF to treat bulk_destroy as a built-in operation
This commit is contained in:
@ -4,11 +4,22 @@ from rest_framework import authentication, exceptions
|
||||
from rest_framework.pagination import LimitOffsetPagination
|
||||
from rest_framework.permissions import DjangoObjectPermissions, SAFE_METHODS
|
||||
from rest_framework.renderers import BrowsableAPIRenderer
|
||||
from rest_framework.schemas import coreapi
|
||||
from rest_framework.utils import formatting
|
||||
|
||||
from users.models import Token
|
||||
|
||||
|
||||
def is_custom_action(action):
|
||||
return action not in {
|
||||
'retrieve', 'list', 'create', 'update', 'partial_update', 'destroy', 'bulk_destroy'
|
||||
}
|
||||
|
||||
|
||||
# Monkey-patch DRF to treat bulk_destroy() as a non-custom action (see #3436)
|
||||
coreapi.is_custom_action = is_custom_action
|
||||
|
||||
|
||||
#
|
||||
# Renderers
|
||||
#
|
||||
|
@ -472,6 +472,13 @@ REST_FRAMEWORK = {
|
||||
'DEFAULT_VERSION': REST_FRAMEWORK_VERSION,
|
||||
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.AcceptHeaderVersioning',
|
||||
'PAGE_SIZE': PAGINATE_COUNT,
|
||||
'SCHEMA_COERCE_METHOD_NAMES': {
|
||||
# Default mappings
|
||||
'retrieve': 'read',
|
||||
'destroy': 'delete',
|
||||
# Custom operations
|
||||
'bulk_destroy': 'bulk_delete',
|
||||
},
|
||||
'VIEW_NAME_FUNCTION': 'netbox.api.get_view_name',
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user