mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-16 09:46:31 +00:00
Draft API endpoint RUD class
- RUD = Retrieve / Update / Destroy - When issuing an Update command, the validity is checked but the model object is only saved if the POST data has "_is_final": true
This commit is contained in:
17
InvenTree/InvenTree/serializers.py
Normal file
17
InvenTree/InvenTree/serializers.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_framework import generics
|
||||
from rest_framework import mixins
|
||||
|
||||
class DraftRUDView(generics.RetrieveAPIView, generics.UpdateAPIView, generics.DestroyAPIView):
|
||||
|
||||
def perform_update(self, serializer):
|
||||
|
||||
ctx_data = serializer._context['request'].data
|
||||
|
||||
if ctx_data.get('_is_final', False) in [True, u'true', u'True', 1]:
|
||||
super(generics.UpdateAPIView, self).perform_update(serializer)
|
||||
else:
|
||||
pass
|
@@ -92,7 +92,8 @@ TEMPLATES = [
|
||||
]
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'EXCEPTION_HANDLER': 'InvenTree.utils.api_exception_handler',
|
||||
'EXCEPTION_HANDLER': 'rest_framework.views.exception_handler'
|
||||
# 'EXCEPTION_HANDLER': 'InvenTree.utils.api_exception_handler',
|
||||
# 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
# 'PAGE_SIZE': 50,
|
||||
}
|
||||
|
Reference in New Issue
Block a user