fix(web): make calculator available without login
This commit is contained in:
1 parent
111623994e
commit
f73f99068a
4 files changed
+3
-30
No files matched your search
@@ -26,6 +26,7 @@
|
|||||||
- 2026-08-21: CI final images use immutable registry base images. Any runtime dependency change requires rebuilding/pushing the matching base (`Dockerfile.base` for `requirements.txt`, `Dockerfile.gateway-base` for `nginx.conf`) and changing the tag used by the final Dockerfile.
|
- 2026-08-21: CI final images use immutable registry base images. Any runtime dependency change requires rebuilding/pushing the matching base (`Dockerfile.base` for `requirements.txt`, `Dockerfile.gateway-base` for `nginx.conf`) and changing the tag used by the final Dockerfile.
|
||||||
- 2026-08-21: use Context7 for fresh official integration documentation and `prevent-eol` before dependency changes; lifecycle status is not a vulnerability verdict.
|
- 2026-08-21: use Context7 for fresh official integration documentation and `prevent-eol` before dependency changes; lifecycle status is not a vulnerability verdict.
|
||||||
- 2026-08-21: project-local frontend instructions include `frontend-craft`, `frontend-design`, and `ui-ux-pro-max`; use them together for UI work.
|
- 2026-08-21: project-local frontend instructions include `frontend-craft`, `frontend-design`, and `ui-ux-pro-max`; use them together for UI work.
|
||||||
|
- 2026-08-21: the public calculator and screenshot upload endpoint do not require `BELKI_WEB_PASSWORD`; password-gated access is limited to applications and admin flows.
|
||||||
# 2026-08-16 — несколько котят в прокачке
|
# 2026-08-16 — несколько котят в прокачке
|
||||||
|
|
||||||
`CoachingSession.extra_kittens` теперь влияет на баллы сопровождающего через количество подопечных: 1-й ×1, 2-й ×1,5, каждый последующий ×1,15 (коэффициенты перемножаются), вместо сложения полной прибыли. Базовый коэффициент самостоятельности основного котёнка сохраняется. Веб-форма отправляет список `extra_kittens`; VK принимает `доп. котята: ...` в pipe-команде.
|
`CoachingSession.extra_kittens` теперь влияет на баллы сопровождающего через количество подопечных: 1-й ×1, 2-й ×1,5, каждый последующий ×1,15 (коэффициенты перемножаются), вместо сложения полной прибыли. Базовый коэффициент самостоятельности основного котёнка сохраняется. Веб-форма отправляет список `extra_kittens`; VK принимает `доп. котята: ...` в pipe-команде.
|
||||||
+1
-1
@@ -194,7 +194,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
token = next((part.strip().split("=", 1)[1] for part in cookies.split(";") if part.strip().startswith("belki_session=")), "")
|
token = next((part.strip().split("=", 1)[1] for part in cookies.split(";") if part.strip().startswith("belki_session=")), "")
|
||||||
_WEB_SESSIONS.discard(token)
|
_WEB_SESSIONS.discard(token)
|
||||||
self._json_with_cookie(200, {"authenticated": False}, "belki_session=; Path=/; Max-Age=0; HttpOnly; SameSite=Lax")
|
self._json_with_cookie(200, {"authenticated": False}, "belki_session=; Path=/; Max-Age=0; HttpOnly; SameSite=Lax")
|
||||||
elif not self._web_authorized():
|
elif self.path == "/api/applications" and not self._web_authorized():
|
||||||
return
|
return
|
||||||
elif self.path == "/api/web/upload":
|
elif self.path == "/api/web/upload":
|
||||||
raw = str(payload.get("data", ""))
|
raw = str(payload.get("data", ""))
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
- GitLab Runner retries source checkout up to three times (`GET_SOURCES_ATTEMPTS=3`) to absorb transient connectivity failures before the job script starts. A persistent inability to reach `git.nyan404.ru:443` still requires repair on the selected runner host.
|
- GitLab Runner retries source checkout up to three times (`GET_SOURCES_ATTEMPTS=3`) to absorb transient connectivity failures before the job script starts. A persistent inability to reach `git.nyan404.ru:443` still requires repair on the selected runner host.
|
||||||
- The local image is currently `belki-calculator:test`; the CI target is now `$DOCKER_REGISTRY/belki:latest`.
|
- The local image is currently `belki-calculator:test`; the CI target is now `$DOCKER_REGISTRY/belki:latest`.
|
||||||
- GitLab CI runs `python -m compileall -q app tests` and `python -m unittest discover -s tests -q` in a dedicated `test` stage before build/deploy. The job explicitly clears `BELKI_DATABASE_URL` and uses `/tmp/belki-test-identities.sqlite3`, preventing unit tests from reaching the Kubernetes PostgreSQL service. Local validation was performed with the same tests, JavaScript syntax check, a local browser/API smoke test, and container health/API smoke.
|
- GitLab CI runs `python -m compileall -q app tests` and `python -m unittest discover -s tests -q` in a dedicated `test` stage before build/deploy. The job explicitly clears `BELKI_DATABASE_URL` and uses `/tmp/belki-test-identities.sqlite3`, preventing unit tests from reaching the Kubernetes PostgreSQL service. Local validation was performed with the same tests, JavaScript syntax check, a local browser/API smoke test, and container health/API smoke.
|
||||||
|
- `/belki` is public: it creates reports and uploads their screenshots without a web-password session. `/applications` and `/admin` remain password-protected.
|
||||||
- The VK dialog layer is covered by tests for step-by-step entry, bulk detection, clarification, confirmation, and cancellation.
|
- The VK dialog layer is covered by tests for step-by-step entry, bulk detection, clarification, confirmation, and cancellation.
|
||||||
- Bulk input accepts a natural one-line format without pipes, e.g. `15.08 11:00 11:20 Дикая Вишня 1604614 Серолап 1617140`; the web form calls `/api/inspect-bulk` and fills recognized fields.
|
- Bulk input accepts a natural one-line format without pipes, e.g. `15.08 11:00 11:20 Дикая Вишня 1604614 Серолап 1617140`; the web form calls `/api/inspect-bulk` and fills recognized fields.
|
||||||
- Training and inspection have the same stepwise/bulk flow. Character identity can be resolved through `/api/resolve-identity` and the persistent SQLite directory; missing pairs produce an explicit prompt instead of guessed data.
|
- Training and inspection have the same stepwise/bulk flow. Character identity can be resolved through `/api/resolve-identity` and the persistent SQLite directory; missing pairs produce an explicit prompt instead of guessed data.
|
||||||
|
|||||||
@@ -45,13 +45,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<section class="panel auth-panel" id="webAuth">
|
|
||||||
<h2>Вход в калькулятор</h2>
|
|
||||||
<p class="muted">Введите пароль, чтобы создавать отчёты и загружать скриншоты.</p>
|
|
||||||
<form id="webAuthForm"><label>Пароль<input id="webPassword" type="password" autocomplete="current-password" required></label><button class="primary" type="submit">Войти</button></form>
|
|
||||||
<p class="error" id="webAuthError"></p>
|
|
||||||
</section>
|
|
||||||
<div id="webApp" class="hidden">
|
|
||||||
<h1>Беличья нора — калькулятор отчётов</h1>
|
<h1>Беличья нора — калькулятор отчётов</h1>
|
||||||
<p class="muted">Один заход — один отчёт. Скриншоты к готовому отчёту нужно приложить вручную.</p>
|
<p class="muted">Один заход — один отчёт. Скриншоты к готовому отчёту нужно приложить вручную.</p>
|
||||||
|
|
||||||
@@ -135,7 +128,6 @@
|
|||||||
<div class="result hidden" id="result"><h2>Сообщение</h2><textarea id="message" readonly></textarea><p class="muted" id="summary"></p></div>
|
<div class="result hidden" id="result"><h2>Сообщение</h2><textarea id="message" readonly></textarea><p class="muted" id="summary"></p></div>
|
||||||
<p class="error" id="error"></p>
|
<p class="error" id="error"></p>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
<dialog id="identityDialog">
|
<dialog id="identityDialog">
|
||||||
<p id="identityDialogText"></p>
|
<p id="identityDialogText"></p>
|
||||||
@@ -145,11 +137,6 @@
|
|||||||
<button type="button" id="closeIdentityDialog">Понятно</button>
|
<button type="button" id="closeIdentityDialog">Понятно</button>
|
||||||
</dialog>
|
</dialog>
|
||||||
<script>
|
<script>
|
||||||
const webAuth = document.querySelector('#webAuth');
|
|
||||||
const webApp = document.querySelector('#webApp');
|
|
||||||
const webAuthForm = document.querySelector('#webAuthForm');
|
|
||||||
const webPassword = document.querySelector('#webPassword');
|
|
||||||
const webAuthError = document.querySelector('#webAuthError');
|
|
||||||
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');
|
||||||
@@ -165,22 +152,6 @@
|
|||||||
const identityMissingLabel = document.querySelector('#identityMissingLabel');
|
const identityMissingLabel = document.querySelector('#identityMissingLabel');
|
||||||
const identityMissingValue = document.querySelector('#identityMissingValue');
|
const identityMissingValue = document.querySelector('#identityMissingValue');
|
||||||
let mode = 'coaching';
|
let mode = 'coaching';
|
||||||
function showWebApp() { webAuth.classList.add('hidden'); webApp.classList.remove('hidden'); }
|
|
||||||
async function checkWebSession() {
|
|
||||||
const response = await fetch('/api/web/session');
|
|
||||||
const data = await response.json();
|
|
||||||
if (data.authenticated) showWebApp();
|
|
||||||
}
|
|
||||||
webAuthForm.addEventListener('submit', async event => {
|
|
||||||
event.preventDefault(); webAuthError.textContent = '';
|
|
||||||
try {
|
|
||||||
const response = await fetch('/api/web/auth', {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({password: webPassword.value})});
|
|
||||||
const data = await response.json();
|
|
||||||
if (!response.ok) throw new Error(data.error || 'Не удалось войти');
|
|
||||||
showWebApp();
|
|
||||||
} catch (err) { webAuthError.textContent = err.message; }
|
|
||||||
});
|
|
||||||
checkWebSession().catch(err => { webAuthError.textContent = err.message; });
|
|
||||||
const extraKittens = document.querySelector('#extraKittens');
|
const extraKittens = document.querySelector('#extraKittens');
|
||||||
const statusHelp = document.querySelector('#statusHelp');
|
const statusHelp = document.querySelector('#statusHelp');
|
||||||
function addExtraKitten(values = {}) {
|
function addExtraKitten(values = {}) {
|
||||||
|
|||||||
Reference in new issue
Block a user