feat: require explicit report submission
This commit is contained in:
1 parent
8519c97678
commit
3c40bff4e8
4 files changed
+41
-5
No files matched your search
+6
-3
@@ -12,7 +12,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import parse_qs, unquote, urlparse
|
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.history import CalculationStore
|
||||||
from .belki.applications import ApplicationError, ApplicationStore, validate_application
|
from .belki.applications import ApplicationError, ApplicationStore, validate_application
|
||||||
from .belki.google_sheets_export import GoogleSheetsExportService
|
from .belki.google_sheets_export import GoogleSheetsExportService
|
||||||
@@ -403,7 +403,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
parsed = urlparse(self.path)
|
parsed = urlparse(self.path)
|
||||||
is_sudoku_create = parsed.path == "/api/sudoku/games"
|
is_sudoku_create = parsed.path == "/api/sudoku/games"
|
||||||
is_sudoku_regenerate = parsed.path.startswith("/api/sudoku/games/") and parsed.path.endswith("/regenerate")
|
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:
|
"/api/applications") and not is_sudoku_create and not is_sudoku_regenerate:
|
||||||
self._json(404, {"error": "Не найдено"})
|
self._json(404, {"error": "Не найдено"})
|
||||||
return
|
return
|
||||||
@@ -467,9 +467,12 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
application_id = application_store().create(application=application, actor_id=None, reply_peer_id=None, source="web")
|
application_id = application_store().create(application=application, actor_id=None, reply_peer_id=None, source="web")
|
||||||
sync_application_exports()
|
sync_application_exports()
|
||||||
self._json(201, {"id": application_id, "status": "pending", "message": "Заявка отправлена на рассмотрение."})
|
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:
|
else:
|
||||||
payload["attachments"] = validate_web_attachments(payload.get("attachments", []))
|
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:
|
except (ApiError, ApplicationError, SudokuError) as exc:
|
||||||
self._json(400, {"error": str(exc)})
|
self._json(400, {"error": str(exc)})
|
||||||
except (ValueError, json.JSONDecodeError) as exc:
|
except (ValueError, json.JSONDecodeError) as exc:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 20. Явная отправка итогового отчёта из веб-формы
|
## 20. Явная отправка итогового отчёта из веб-формы
|
||||||
|
|
||||||
**Статус:** ожидает исправления.
|
**Статус:** выполнено 25.08.2026.
|
||||||
|
|
||||||
**Источник:** сообщение пользователя со скриншотом от 25.08.2026.
|
**Источник:** сообщение пользователя со скриншотом от 25.08.2026.
|
||||||
|
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
- повторное нажатие не создаёт дубликат отчёта;
|
- повторное нажатие не создаёт дубликат отчёта;
|
||||||
- пользователь может скопировать подготовленный текст до отправки.
|
- пользователь может скопировать подготовленный текст до отправки.
|
||||||
|
|
||||||
|
**Исправление:** `/api/calculate` теперь только подготавливает расчёт и сообщение. Итог сохраняется отдельным запросом к `/api/reports` после нажатия «Отправить отчёт»; кнопка сразу блокируется, а после успеха показывается текстовое подтверждение.
|
||||||
|
|
||||||
## 19. В калькуляторе прокачки начало и конец должны быть в одной строке
|
## 19. В калькуляторе прокачки начало и конец должны быть в одной строке
|
||||||
|
|
||||||
**Статус:** выполнено 25.08.2026.
|
**Статус:** выполнено 25.08.2026.
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
- 2026-08-25: the deploy job waits for `deployment/belki-postgres` to become `Available`, rather than waiting for every Pod with the shared PostgreSQL label. Historical ReplicaSet Pods can remain during cleanup and must not fail a release after the current database replica is ready.
|
- 2026-08-25: the deploy job waits for `deployment/belki-postgres` to become `Available`, rather than waiting for every Pod with the shared PostgreSQL label. Historical ReplicaSet Pods can remain during cleanup and must not fail a release after the current database replica is ready.
|
||||||
- 2026-08-25: coaching reports allow an independence status for every kitten in both ЛУ and ЗУ. Natural input attaches `сам`/`не сам` written after a participant ID to that participant, and web ID fields use numeric-text input instead of spinner controls.
|
- 2026-08-25: coaching reports allow an independence status for every kitten in both ЛУ and ЗУ. Natural input attaches `сам`/`не сам` written after a participant ID to that participant, and web ID fields use numeric-text input instead of spinner controls.
|
||||||
- 2026-08-25: the earned-points calculator groups coaching start and end times in one responsive time-range row.
|
- 2026-08-25: the earned-points calculator groups coaching start and end times in one responsive time-range row.
|
||||||
|
- 2026-08-25: web reports use a two-step flow: `/api/calculate` prepares the message without saving it, then `/api/reports` stores it only after the user explicitly selects «Отправить отчёт». The UI disables that action while it is in progress and after success.
|
||||||
- 2026-08-25: removed unreferenced root-level legacy BBCode copies `belki.md`, `belki2.md`, and `belkifix.md`; the first two were byte-identical and the third differed only by a closing BBCode tag. They were neither served nor referenced by the calculator, bot, or documentation.
|
- 2026-08-25: removed unreferenced root-level legacy BBCode copies `belki.md`, `belki2.md`, and `belkifix.md`; the first two were byte-identical and the third differed only by a closing BBCode tag. They were neither served nor referenced by the calculator, bot, or documentation.
|
||||||
# Обновление 2026-08-16: несколько котят
|
# Обновление 2026-08-16: несколько котят
|
||||||
|
|
||||||
|
|||||||
+31
-1
@@ -178,7 +178,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
<div class="result hidden" id="result"><h2>Сообщение</h2><textarea id="message" readonly></textarea></div>
|
<div class="result hidden" id="result"><h2>Сообщение</h2><textarea id="message" readonly></textarea><div class="actions"><button type="button" id="sendReport" class="primary" disabled>Отправить отчёт</button></div><p class="muted hidden" id="reportStatus" aria-live="polite"></p></div>
|
||||||
<div class="result hidden" id="pointsResult" aria-live="polite"><h2>Заработанные баллы</h2><div id="pointsSummary"></div></div>
|
<div class="result hidden" id="pointsResult" aria-live="polite"><h2>Заработанные баллы</h2><div id="pointsSummary"></div></div>
|
||||||
<p class="error" id="error"></p>
|
<p class="error" id="error"></p>
|
||||||
</section>
|
</section>
|
||||||
@@ -223,6 +223,9 @@
|
|||||||
const form = document.querySelector('#form');
|
const form = document.querySelector('#form');
|
||||||
const error = document.querySelector('#error');
|
const error = document.querySelector('#error');
|
||||||
const result = document.querySelector('#result');
|
const result = document.querySelector('#result');
|
||||||
|
const sendReport = document.querySelector('#sendReport');
|
||||||
|
const reportStatus = document.querySelector('#reportStatus');
|
||||||
|
let preparedReportPayload = null;
|
||||||
const message = document.querySelector('#message');
|
const message = document.querySelector('#message');
|
||||||
const copy = document.querySelector('#copy');
|
const copy = document.querySelector('#copy');
|
||||||
const goalCopy = document.querySelector('#goalCopy');
|
const goalCopy = document.querySelector('#goalCopy');
|
||||||
@@ -429,6 +432,9 @@
|
|||||||
if (statusError) throw new Error(statusError);
|
if (statusError) throw new Error(statusError);
|
||||||
}
|
}
|
||||||
const reportPayload = payload();
|
const reportPayload = payload();
|
||||||
|
preparedReportPayload = null;
|
||||||
|
reportStatus.classList.add('hidden');
|
||||||
|
reportStatus.textContent = '';
|
||||||
reportPayload.attachments = mode === 'goal' ? [] : await uploadScreenshots();
|
reportPayload.attachments = mode === 'goal' ? [] : await uploadScreenshots();
|
||||||
const response = await fetch('/api/calculate', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(reportPayload) });
|
const response = await fetch('/api/calculate', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(reportPayload) });
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
@@ -443,8 +449,32 @@
|
|||||||
result.classList.remove('hidden');
|
result.classList.remove('hidden');
|
||||||
copy.disabled = mode === 'goal';
|
copy.disabled = mode === 'goal';
|
||||||
goalCopy.disabled = mode !== 'goal';
|
goalCopy.disabled = mode !== 'goal';
|
||||||
|
sendReport.classList.toggle('hidden', mode === 'goal');
|
||||||
|
if (mode !== 'goal') {
|
||||||
|
preparedReportPayload = reportPayload;
|
||||||
|
sendReport.disabled = false;
|
||||||
|
sendReport.textContent = 'Отправить отчёт';
|
||||||
|
}
|
||||||
} catch (err) { error.textContent = err.message; }
|
} catch (err) { error.textContent = err.message; }
|
||||||
});
|
});
|
||||||
|
sendReport.addEventListener('click', async () => {
|
||||||
|
if (!preparedReportPayload || sendReport.disabled) return;
|
||||||
|
sendReport.disabled = true;
|
||||||
|
sendReport.textContent = 'Отправляем…';
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/reports', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(preparedReportPayload) });
|
||||||
|
const data = await response.json();
|
||||||
|
if (!response.ok) throw new Error(data.error || 'Не удалось отправить отчёт');
|
||||||
|
preparedReportPayload = null;
|
||||||
|
sendReport.textContent = 'Отчёт отправлен';
|
||||||
|
reportStatus.textContent = 'Отчёт отправлен и сохранён.';
|
||||||
|
reportStatus.classList.remove('hidden');
|
||||||
|
} catch (err) {
|
||||||
|
error.textContent = err.message;
|
||||||
|
sendReport.disabled = false;
|
||||||
|
sendReport.textContent = 'Отправить отчёт';
|
||||||
|
}
|
||||||
|
});
|
||||||
copy.addEventListener('click', async () => { await navigator.clipboard.writeText(message.value); copy.textContent = 'Скопировано'; setTimeout(() => copy.textContent = 'Скопировать', 1500); });
|
copy.addEventListener('click', async () => { await navigator.clipboard.writeText(message.value); copy.textContent = 'Скопировано'; setTimeout(() => copy.textContent = 'Скопировать', 1500); });
|
||||||
goalCopy.addEventListener('click', async () => { await navigator.clipboard.writeText(message.value); goalCopy.textContent = 'Скопировано'; setTimeout(() => goalCopy.textContent = 'Скопировать', 1500); });
|
goalCopy.addEventListener('click', async () => { await navigator.clipboard.writeText(message.value); goalCopy.textContent = 'Скопировано'; setTimeout(() => goalCopy.textContent = 'Скопировать', 1500); });
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user