diff --git a/src/apps/parsers/source_registry.py b/src/apps/parsers/source_registry.py index 8843a8c..744a2cc 100644 --- a/src/apps/parsers/source_registry.py +++ b/src/apps/parsers/source_registry.py @@ -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: diff --git a/src/apps/parsers/urls.py b/src/apps/parsers/urls.py index 493680a..609705a 100644 --- a/src/apps/parsers/urls.py +++ b/src/apps/parsers/urls.py @@ -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//", + SourceResultListView.as_view(), + name="source-result-list", + ), + path( + "results///", + SourceResultDetailView.as_view(), + name="source-result-detail", + ), path( "schedules/", ParserScheduleListCreateView.as_view(), diff --git a/src/apps/parsers/views.py b/src/apps/parsers/views.py index db5e2b2..f6ace39 100644 --- a/src/apps/parsers/views.py +++ b/src/apps/parsers/views.py @@ -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) diff --git a/src/settings/dev.py b/src/settings/dev.py index c5dac60..2cd49f9 100644 --- a/src/settings/dev.py +++ b/src/settings/dev.py @@ -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 на хосте.""" diff --git a/src/templates/dashboard.html b/src/templates/dashboard.html index c9c22ed..2da3874 100644 --- a/src/templates/dashboard.html +++ b/src/templates/dashboard.html @@ -1,9 +1,11 @@ - + Mostovik Parser Dashboard + +