diff --git a/api/directions/views.py b/api/directions/views.py index 79f36363f5..3252f743c4 100644 --- a/api/directions/views.py +++ b/api/directions/views.py @@ -3877,6 +3877,12 @@ def eds_documents(request): if not direction.is_all_confirm(): return status_response(False, 'Направление должно быть подтверждено!') + documents = process_to_sign_direction(direction, pk, request.user, iss_obj) + + return JsonResponse({"documents": documents, "edsTitle": direction.get_eds_title(), "executors": direction.get_executors()}) + + +def process_to_sign_direction(direction, pk, user, iss_obj): required_signatures = direction.required_signatures(need_save=True) documents = [] @@ -3926,7 +3932,7 @@ def eds_documents(request): "inline": '1', "protocol_plain_text": '1', }, - 'user': request.user, + 'user': user, 'plain_response': True, } filename = f'{pk}-{last_time_confirm}.pdf' @@ -3969,8 +3975,7 @@ def eds_documents(request): } documents.append(document) - - return JsonResponse({"documents": documents, "edsTitle": direction.get_eds_title(), "executors": direction.get_executors()}) + return documents @login_required diff --git a/api/management/commands/auto_load_protocol.py b/api/management/commands/auto_load_protocol.py index 54f3adbdba..ee307574d2 100644 --- a/api/management/commands/auto_load_protocol.py +++ b/api/management/commands/auto_load_protocol.py @@ -14,9 +14,7 @@ from django.utils import timezone from utils.nsi_directories import NSI -import simplejson as json -from django.http import HttpRequest -from api.directions.views import eds_documents +from api.directions.views import process_to_sign_direction logger = logging.getLogger("IF") @@ -166,15 +164,12 @@ def handle(self, *args, **kwargs): continue directions.ParaclinicResult(issledovaniye=iss, field=f, field_type=f.field_type, value=data_result.get(f.title)).save() stdout.write(f"Добавлена карта: \n, {direction.pk}, {card}") - eds_documents_data = json.dumps({"pk": direction.pk}) - eds_documents_obj = HttpRequest() - eds_documents_obj._body = eds_documents_data - eds_documents_obj.user = doc_profile.user - eds_documents(eds_documents_obj) + result = process_to_sign_direction(direction, direction.pk, doc_profile.user, iss) + stdout.write(f"sign_data: {result}") except Exception as e: logger.exception(e) message = "Серверная ошибка" return {"ok": False, "message": message} - step += 1 - stdout.write(f"{step}") - stdout.write(f"Добавлена карта: \n, {direction.pk}, {card}") + step += 1 + stdout.write(f"{step}") + stdout.write(f"Добавлена карта: \n, {direction.pk}, {card}")