refactor(fns): переместить роуты /api/v1/parsers/fns → /api/v1/fns
- Упростить URL: /api/v1/fns/reports/, /api/v1/fns/upload/ - Добавить swagger теги для группировки в документации
This commit is contained in:
@@ -35,9 +35,10 @@
|
||||
- Перемещение файлов в `processed/` или `failed/`
|
||||
|
||||
- **API endpoints** (`views.py`, `urls.py`):
|
||||
- `POST /api/v1/parsers/fns/upload/` — пакетная загрузка файлов
|
||||
- `GET /api/v1/parsers/fns/reports/` — список отчетов с фильтрацией
|
||||
- `GET /api/v1/parsers/fns/reports/{id}/` — детали отчета со строками
|
||||
- `POST /api/v1/fns/upload/` — пакетная загрузка файлов
|
||||
- `GET /api/v1/fns/reports/` — список отчетов с фильтрацией
|
||||
- `GET /api/v1/fns/reports/{id}/` — детали отчета со строками
|
||||
- Swagger теги для группировки в документации
|
||||
|
||||
- **Админка** (`admin.py`):
|
||||
- `FinancialReportAdmin` с inline для строк
|
||||
|
||||
@@ -4,10 +4,13 @@ from rest_framework.routers import DefaultRouter
|
||||
|
||||
app_name = "parsers"
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r"fns/reports", FinancialReportViewSet, basename="fns-reports")
|
||||
# FNS router
|
||||
fns_router = DefaultRouter()
|
||||
fns_router.register(r"reports", FinancialReportViewSet, basename="fns-reports")
|
||||
|
||||
urlpatterns = [
|
||||
path("fns/upload/", FNSReportUploadView.as_view(), name="fns-upload"),
|
||||
path("", include(router.urls)),
|
||||
fns_urlpatterns = [
|
||||
path("upload/", FNSReportUploadView.as_view(), name="fns-upload"),
|
||||
path("", include(fns_router.urls)),
|
||||
]
|
||||
|
||||
urlpatterns = []
|
||||
|
||||
@@ -13,12 +13,15 @@ from apps.parsers.serializers import (
|
||||
)
|
||||
from apps.parsers.tasks import process_fns_file
|
||||
from django.conf import settings
|
||||
from drf_yasg.utils import swagger_auto_schema
|
||||
from rest_framework import status
|
||||
from rest_framework.parsers import MultiPartParser
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
|
||||
FNS_TAG = "ФНС - Бухгалтерская отчетность"
|
||||
|
||||
|
||||
class FinancialReportViewSet(ReadOnlyModelViewSet):
|
||||
"""
|
||||
@@ -40,6 +43,14 @@ class FinancialReportViewSet(ReadOnlyModelViewSet):
|
||||
return FinancialReportDetailSerializer
|
||||
return FinancialReportSerializer
|
||||
|
||||
@swagger_auto_schema(tags=[FNS_TAG])
|
||||
def list(self, request, *args, **kwargs):
|
||||
return super().list(request, *args, **kwargs)
|
||||
|
||||
@swagger_auto_schema(tags=[FNS_TAG])
|
||||
def retrieve(self, request, *args, **kwargs):
|
||||
return super().retrieve(request, *args, **kwargs)
|
||||
|
||||
|
||||
class FNSReportUploadView(APIView):
|
||||
"""
|
||||
@@ -63,6 +74,7 @@ class FNSReportUploadView(APIView):
|
||||
|
||||
parser_classes = [MultiPartParser]
|
||||
|
||||
@swagger_auto_schema(tags=[FNS_TAG], request_body=FNSFileUploadSerializer)
|
||||
def post(self, request):
|
||||
serializer = FNSFileUploadSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
|
||||
@@ -5,6 +5,7 @@ All API endpoints are versioned under /api/v1/
|
||||
"""
|
||||
|
||||
from apps.core.views import BackgroundJobListView, BackgroundJobStatusView
|
||||
from apps.parsers.urls import fns_urlpatterns
|
||||
from django.urls import include, path
|
||||
|
||||
app_name = "api_v1"
|
||||
@@ -16,6 +17,6 @@ jobs_urlpatterns = [
|
||||
|
||||
urlpatterns = [
|
||||
path("users/", include("apps.user.urls")),
|
||||
path("parsers/", include("apps.parsers.urls")),
|
||||
path("fns/", include((fns_urlpatterns, "fns"))),
|
||||
path("jobs/", include((jobs_urlpatterns, "jobs"))),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user