api update
This commit is contained in:
parent
4ff48110e1
commit
e4c439c7cd
@ -10,6 +10,9 @@ from django.db.models import Q
|
|||||||
from drf_spectacular.utils import extend_schema, OpenApiParameter, OpenApiTypes
|
from drf_spectacular.utils import extend_schema, OpenApiParameter, OpenApiTypes
|
||||||
# from drf_spectacular.types import OpenApiString
|
# from drf_spectacular.types import OpenApiString
|
||||||
from ..models import SubscriptionRequest
|
from ..models import SubscriptionRequest
|
||||||
|
from ..exception.exceptions import RequiredFieldException
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
class AccuracyViewSet(viewsets.ViewSet):
|
class AccuracyViewSet(viewsets.ViewSet):
|
||||||
@ -238,7 +241,8 @@ class RequestViewSet(viewsets.ViewSet):
|
|||||||
'Server Processing Time (ms)': subscription_request.preprocessing_time + subscription_request.ai_inference_time,
|
'Server Processing Time (ms)': subscription_request.preprocessing_time + subscription_request.ai_inference_time,
|
||||||
'Is Reviewed': subscription_request.is_reviewed,
|
'Is Reviewed': subscription_request.is_reviewed,
|
||||||
# 'Is Bad Quality': subscription_request.is_bad_image_quality,
|
# 'Is Bad Quality': subscription_request.is_bad_image_quality,
|
||||||
'created_at': subscription_request.created_at.isoformat()
|
'created_at': subscription_request.created_at.isoformat(),
|
||||||
|
'updated_at': subscription_request.updated_at.isoformat()
|
||||||
})
|
})
|
||||||
|
|
||||||
response = {
|
response = {
|
||||||
@ -254,11 +258,14 @@ class RequestViewSet(viewsets.ViewSet):
|
|||||||
|
|
||||||
subscription_request = SubscriptionRequest.objects.filter(base_query).first()
|
subscription_request = SubscriptionRequest.objects.filter(base_query).first()
|
||||||
|
|
||||||
try:
|
reviewed_result = json.loads(data["reviewed_result"][1:-1])
|
||||||
subscription_request.reviewed_result = data['reviewed_result']
|
for field in ['retailername', 'sold_to_party', 'purchase_date', 'imei_number']:
|
||||||
except Exception as e:
|
if not field in reviewed_result.keys():
|
||||||
print(f"[ERROR]: {e}")
|
raise RequiredFieldException(excArgs=f'reviewed_result.{field}')
|
||||||
print(f"[ERROR]: {subscription_request}")
|
subscription_request.reviewed_result = reviewed_result
|
||||||
|
subscription_request.reviewed_result['request_id'] = request_id
|
||||||
|
subscription_request.is_reviewed = True
|
||||||
|
subscription_request.save()
|
||||||
|
|
||||||
return JsonResponse({'message': 'success.'}, status=200)
|
return JsonResponse({'message': 'success.'}, status=200)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user