Delete a Profiler entry (requires typing first+last name). Requested safety: user must type the profile's first and last name before deletion.
(eid: int)
| 16340 | stored_path = os.path.join(ATT_DIR, f"prof_att_{aid}.bin") |
| 16341 | try: |
| 16342 | size = _save_plain_upload(file_storage, stored_path) |
| 16343 | # Keep profiler attachments reasonably bounded to avoid DoS. |
| 16344 | if int(size) > CHAT_MAX_BYTES: |
| 16345 | try: |
| 16346 | os.remove(stored_path) |
| 16347 | except Exception: |
| 16348 | pass |
| 16349 | conn.execute("DELETE FROM profiler_attachments WHERE id=?", (aid,)) |
| 16350 | conn.commit() |
| 16351 | conn.close() |
| 16352 | raise ValueError("too_large") |
| 16353 | conn.execute("UPDATE profiler_attachments SET stored_path=? WHERE id=?", (stored_path, aid)) |
| 16354 | conn.commit() |
| 16355 | finally: |
| 16356 | try: |
| 16357 | conn.close() |
| 16358 | except Exception: |
| 16359 | pass |
| 16360 | |
| 16361 | |
| 16362 | def _bounty_currency_symbol() -> str: |
| 16363 | try: |
| 16364 | return "€" if get_lang() == "el" else "$" |
| 16365 | except Exception: |
| 16366 | return "$" |
| 16367 | |
| 16368 | def _fmt_bounty_amount_plain(val: Any) -> str: |
| 16369 | try: |
| 16370 | f = float(val) |
| 16371 | except Exception: |
| 16372 | return "" |
| 16373 | if f.is_integer(): |
| 16374 | return str(int(f)) |
| 16375 | s = f"{f:.2f}".rstrip("0").rstrip(".") |
| 16376 | return s or "0" |
| 16377 | |
| 16378 | def _fmt_bounty_price(val: Any) -> str: |
| 16379 | """Format bounty price with localized currency symbol.""" |
| 16380 | amt = _fmt_bounty_amount_plain(val) |
| 16381 | if not amt: |
| 16382 | return "" |
| 16383 | return f"{_bounty_currency_symbol()}{amt}" |
| 16384 | |
| 16385 | def _complete_login_session(username: str, is_admin: bool) -> Response: |
| 16386 | # Drop stale session data on successful login while keeping a fresh CSRF token. |
| 16387 | try: |
nothing calls this directly
no test coverage detected