feat: require explicit report submission

This commit is contained in:
nyan404 committed 2026-08-25 21:38:11 +03:00
1 parent 8519c97678
commit 3c40bff4e8
4 files changed
+41 -5

No files matched your search

+6 -3
View File
@@ -12,7 +12,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from urllib.parse import parse_qs, unquote, urlparse
from .belki.api import ApiError, calculate_and_store, inspect_bulk_payload, resolve_identity_payload
from .belki.api import ApiError, calculate_and_store, calculate_payload, inspect_bulk_payload, resolve_identity_payload
from .belki.history import CalculationStore
from .belki.applications import ApplicationError, ApplicationStore, validate_application
from .belki.google_sheets_export import GoogleSheetsExportService
@@ -403,7 +403,7 @@ class Handler(BaseHTTPRequestHandler):
parsed = urlparse(self.path)
is_sudoku_create = parsed.path == "/api/sudoku/games"
is_sudoku_regenerate = parsed.path.startswith("/api/sudoku/games/") and parsed.path.endswith("/regenerate")
if self.path not in ("/api/admin/auth", "/api/admin/logout", "/api/web/upload", "/api/calculate", "/api/inspect-bulk", "/api/resolve-identity",
if self.path not in ("/api/admin/auth", "/api/admin/logout", "/api/web/upload", "/api/calculate", "/api/reports", "/api/inspect-bulk", "/api/resolve-identity",
"/api/applications") and not is_sudoku_create and not is_sudoku_regenerate:
self._json(404, {"error": "Не найдено"})
return
@@ -467,9 +467,12 @@ class Handler(BaseHTTPRequestHandler):
application_id = application_store().create(application=application, actor_id=None, reply_peer_id=None, source="web")
sync_application_exports()
self._json(201, {"id": application_id, "status": "pending", "message": "Заявка отправлена на рассмотрение."})
elif self.path == "/api/calculate":
payload["attachments"] = validate_web_attachments(payload.get("attachments", []))
self._json(200, calculate_payload(payload))
else:
payload["attachments"] = validate_web_attachments(payload.get("attachments", []))
self._json(200, calculate_and_store(payload, actor_id=None, source="web"))
self._json(201, calculate_and_store(payload, actor_id=None, source="web"))
except (ApiError, ApplicationError, SudokuError) as exc:
self._json(400, {"error": str(exc)})
except (ValueError, json.JSONDecodeError) as exc: