feat(dashboard): improve parser API checks
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user