feat(dashboard): improve parser API checks
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 21s
CI/CD Pipeline / Build and Push Images (push) Successful in 6s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s

This commit is contained in:
2026-04-29 11:47:45 +02:00
parent d6de9a27b3
commit be7af18c36
7 changed files with 1548 additions and 121 deletions

View File

@@ -31,12 +31,12 @@ class ParserSourceDescriptor:
@property
def result_list_url(self) -> str:
"""Frontend/API URL для списка результата источника."""
return f"/api/v1/{self.api_route}/" if self.api_route else ""
return f"/api/v1/parsers/results/{self.key}/" if self.api_route else ""
@property
def result_detail_url(self) -> str:
"""Frontend/API URL для карточки результата источника."""
return f"/api/v1/{self.api_route}/{{id}}/" if self.api_route else ""
return f"/api/v1/parsers/results/{self.key}/{{id}}/" if self.api_route else ""
@property
def upload_url(self) -> str:

View File

@@ -26,6 +26,8 @@ from apps.parsers.views import (
SourceCardDetailView,
SourceCardListView,
SourceCardRefreshView,
SourceResultDetailView,
SourceResultListView,
SourceTaskStatusListView,
)
from django.urls import include, path
@@ -134,6 +136,16 @@ urlpatterns = [
ParserUploadView.as_view(),
name="upload-parser-data",
),
path(
"results/<str:source_key>/",
SourceResultListView.as_view(),
name="source-result-list",
),
path(
"results/<str:source_key>/<int:pk>/",
SourceResultDetailView.as_view(),
name="source-result-detail",
),
path(
"schedules/",
ParserScheduleListCreateView.as_view(),

View File

@@ -145,6 +145,7 @@ NATIVE_RECORD_MODELS = {
ParserLoadLog.Source.MANUFACTURES: ManufacturerRecord,
ParserLoadLog.Source.INSPECTIONS: InspectionRecord,
ParserLoadLog.Source.PROCUREMENTS: ProcurementRecord,
ParserLoadLog.Source.FNS_REPORTS: FinancialReport,
}
EXISTING_TASK_PARAMS = {
"industrial": {"proxies", "requested_by_id"},
@@ -1457,6 +1458,15 @@ def _native_record_to_result(
url = record.href
inn = record.customer_inn
ogrn = record.customer_ogrn
elif source == ParserLoadLog.Source.FNS_REPORTS:
external_id = record.external_id
organisation_name = ""
title = record.file_name
record_date = ""
status_value = record.status
url = ""
inn = ""
ogrn = record.ogrn
else:
external_id = record.registration_number
organisation_name = record.organisation_name
@@ -1641,6 +1651,14 @@ def _native_field_map(source: str) -> dict[str, str]:
"record_date": "publish_date",
"status": "status",
}
if source == ParserLoadLog.Source.FNS_REPORTS:
return {
**common,
"external_id": "external_id",
"ogrn": "ogrn",
"title": "file_name",
"status": "status",
}
return {
**common,
"external_id": "registration_number",
@@ -1681,6 +1699,13 @@ def _native_search_q(source: str, search: str) -> Q:
| Q(customer_name__icontains=search)
| Q(customer_inn__icontains=search)
)
if source == ParserLoadLog.Source.FNS_REPORTS:
return (
Q(file_name__icontains=search)
| Q(external_id__icontains=search)
| Q(ogrn__icontains=search)
| Q(status__icontains=search)
)
return (
Q(organisation_name__icontains=search)
| Q(registration_number__icontains=search)

View File

@@ -22,6 +22,19 @@ STATE_CORP_EXCHANGE_TOKEN = os.getenv(
# JWT
SIMPLE_JWT["SIGNING_KEY"] = SECRET_KEY
# Dev frontend can run from any workstation/port in the local network.
# Production keeps the restrictive CORS/CSRF policy from settings.production.
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_PRIVATE_NETWORK = True
CSRF_COOKIE_SECURE = False
SESSION_COOKIE_SECURE = False
MIDDLEWARE = [
middleware
for middleware in MIDDLEWARE
if middleware != "django.middleware.csrf.CsrfViewMiddleware"
]
def _normalize_local_host(host: str) -> str:
"""Нормализует host для локального запуска backend на хосте."""

File diff suppressed because it is too large Load Diff