Split graph/import/meta into Django apps, add API v1 with OpenAPI and pytest, and introduce plugin registry with the tags reference plugin on both FE and BE. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
762 B
Python
20 lines
762 B
Python
from rest_framework import status
|
|
from rest_framework.decorators import api_view
|
|
from rest_framework.response import Response
|
|
|
|
from .services import parse_upload_file, import_contacts_from_rows
|
|
|
|
|
|
@api_view(['POST'])
|
|
def import_contacts(request):
|
|
file = request.FILES.get('file')
|
|
if not file:
|
|
return Response({'error': 'Файл не передан.'}, status=status.HTTP_400_BAD_REQUEST)
|
|
try:
|
|
rows, error = parse_upload_file(file)
|
|
if error:
|
|
return Response({'error': error}, status=status.HTTP_400_BAD_REQUEST)
|
|
return Response(import_contacts_from_rows(rows))
|
|
except Exception as e:
|
|
return Response({'error': f'Ошибка разбора файла: {e}'}, status=status.HTTP_400_BAD_REQUEST)
|