medicine-mts/appa/test_views.py

116 lines
3.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json
import random
from django.utils.crypto import get_random_string
from django.views.decorators.csrf import csrf_exempt
from django.http import JsonResponse
from django.utils.crypto import get_random_string
from appa.models import CallRequest
@csrf_exempt
def auth_view(request):
return JsonResponse({
'accessToken': get_random_string(32),
'refreshToken': get_random_string(32),
})
@csrf_exempt
def add_records_view(request):
data = json.loads(request.body)
results = []
for record in data['records']:
record['id'] = random.randint(1, 10000)
results.append(record)
return JsonResponse({
'added_records': results
})
@csrf_exempt
def get_record_view(request, record_id):
call_request = CallRequest.objects.get(id=record_id)
return JsonResponse({
"middle_name": call_request.middle_name,
"call_date": "2020-06-10",
"mp3_file": "",
"text_log": "",
"id": call_request.call_id,
"first_name": call_request.first_name,
"second_name": call_request.last_name,
"phone_number": call_request.phone_number,
"receipt_date": "2020-06-11",
"receipt_time": "22:39",
"doctor_specialisation": "Окулист",
"doctor_fullname": "Петренко",
"filial": "",
"call_result": "Подтверждено с смс",
"confirmed": true,
"call_result_code": 2,
"call_over": true,
"note": ""
})
@csrf_exempt
def delete_record_view(request, record_id):
pass
@csrf_exempt
def add_error_view(request):
return JsonResponse({
'request_id': get_random_string(10),
'success': '0',
'error': "'number_b' should be in e164 format"
}, status=400)
@csrf_exempt
def add_500_error_view(request):
return JsonResponse({
'status': 500,
'status_message': 'Internal Server Error'
}, status=500)
@csrf_exempt
def history_view(request):
return JsonResponse({
{
"page": 1,
"total": 51046,
"offset": 0,
"limit": 50,
"prev": "",
"next": "https://***/history?date_from=2023-10-12+09%3A00%3A00&date_to=2023-10-12+18%3A05%3A00&limit=50&offset=50",
"talks": [
{
"call_id": "000364fa82e81b0e",
"duration": "43",
"number_a": "74993331122",
"number_b": "79155552211",
"s_date": "2023-10-1209:00:25",
"side": "B",
"link_recording": "https://***/000123fa82e81b0e?date_from=2023-10-12T08:59:25Z&date_to=2023-10-12T09:02:25Z",
"status": "отменитьзаказ",
"transcript": "[Робот,hello_main]текстробота\n[Абонент,Hello]текстабонента\n..."
},
{
"call_id": "002114fa55461eb6",
"duration": "32",
"number_a": "74995443052",
"phone": "79206584411",
"s_date": "2023-10-2219:59:06",
"side": "A",
"link_recording": "https://***/000564fa82e81b0e?date_from=2023-10-12T19:58:06Z&date_to=2023-10-12T20:02:06Z",
"status": "оформитьзаказ",
"transcript": "[Робот,hello_main]текстробота\n[Абонент,Hello]текстабонента\n..."
}
]
}
})