|
|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
# from django.shortcuts import render |
|
|
|
|
import re |
|
|
|
|
import json |
|
|
|
|
from .serializers import DataAccessSerializer |
|
|
|
|
from django.db.models import Q |
|
|
|
|
|
|
|
|
|
@ -95,6 +97,8 @@ class SynchronizationApi(HierarchyApiView): |
|
|
|
|
results = [] |
|
|
|
|
|
|
|
|
|
for op in operations: |
|
|
|
|
result = None |
|
|
|
|
message = None |
|
|
|
|
try: |
|
|
|
|
model_operation = op.get('operation') |
|
|
|
|
model_name = op.get('model_name') |
|
|
|
|
@ -115,7 +119,7 @@ class SynchronizationApi(HierarchyApiView): |
|
|
|
|
response_status = status.HTTP_201_CREATED |
|
|
|
|
else: |
|
|
|
|
print(f'Data invalid ! {serializer.errors}') |
|
|
|
|
result = serializer.errors |
|
|
|
|
message = json.dumps(serializer.errors) |
|
|
|
|
response_status = status.HTTP_400_BAD_REQUEST |
|
|
|
|
elif model_operation == 'PUT': |
|
|
|
|
data_id = data.get('id') |
|
|
|
|
@ -148,13 +152,14 @@ class SynchronizationApi(HierarchyApiView): |
|
|
|
|
response_status = status.HTTP_404_NOT_FOUND |
|
|
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
|
response_status = 'error' |
|
|
|
|
result = str(e) |
|
|
|
|
response_status = status.HTTP_400_BAD_REQUEST |
|
|
|
|
message = str(e) |
|
|
|
|
|
|
|
|
|
results.append({ |
|
|
|
|
'api_call_id': op.get('api_call_id'), |
|
|
|
|
'status': response_status, |
|
|
|
|
'data': result |
|
|
|
|
'data': result, |
|
|
|
|
'message': message |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return Response({ |
|
|
|
|
|