fix: align web reports with current rules
This commit is contained in:
1 parent
cffaaac755
commit
aecbb3bf6a
10 files changed
+47
-12
No files matched your search
+12
-2
@@ -102,6 +102,16 @@ def validate_web_attachments(value: object, *, now: float | None = None) -> list
|
||||
return attachments
|
||||
|
||||
|
||||
def validate_web_report_attachments(payload: dict) -> list[dict]:
|
||||
"""Apply the web rule: screenshots are required only for an inspection."""
|
||||
attachments = validate_web_attachments(payload.get("attachments", []))
|
||||
if payload.get("mode") == "inspection" and not attachments:
|
||||
raise ApiError("Для осмотра приложите хотя бы один скриншот")
|
||||
if payload.get("mode") != "inspection" and attachments:
|
||||
raise ApiError("Скриншоты прикладываются только к осмотрам")
|
||||
return attachments
|
||||
|
||||
|
||||
def allow_admin_auth_attempt(client_ip: str, *, now: float | None = None) -> bool:
|
||||
"""Apply a bounded per-source budget to the password-only admin login."""
|
||||
timestamp = time.monotonic() if now is None else now
|
||||
@@ -531,13 +541,13 @@ class Handler(BaseHTTPRequestHandler):
|
||||
elif self.path == "/api/resolve-identity":
|
||||
self._json(200, resolve_identity_payload(payload))
|
||||
elif self.path == "/api/applications":
|
||||
payload["attachments"] = validate_web_attachments(payload.get("attachments", []))
|
||||
payload["attachments"] = validate_web_report_attachments(payload)
|
||||
application = validate_application(payload)
|
||||
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", []))
|
||||
payload["attachments"] = validate_web_report_attachments(payload)
|
||||
self._json(200, calculate_payload(payload))
|
||||
else:
|
||||
payload["attachments"] = validate_web_attachments(payload.get("attachments", []))
|
||||
|
||||
Reference in new issue
Block a user