Run an interactive approve/deny prompt in the *main thread*. Termux/Android terminals can fail to show `input()` prompts reliably when they happen inside background threads. This function is meant to be called from the main loop so the prompt always appears.
(username: str)
| 16704 | price_raw = (request.form.get("price") or "").strip() |
| 16705 | reason = (request.form.get("reason") or "").strip() |
| 16706 | if not eid: |
| 16707 | flash(_("Select a profile first.")) |
| 16708 | return redirect(url_for("bounty")) |
| 16709 | if not reason: |
| 16710 | flash(_("Bounty reason is required.")) |
| 16711 | return redirect(url_for("bounty", eid=eid)) |
| 16712 | if len(reason) > 333: |
| 16713 | flash(_("Bounty reason must be 333 characters or less.")) |
| 16714 | return redirect(url_for("bounty", eid=eid)) |
| 16715 | try: |
| 16716 | price = float(price_raw.replace(",", "")) |
| 16717 | if price < 0: |
| 16718 | raise ValueError |
| 16719 | except Exception: |
| 16720 | flash(_("Invalid bounty price.")) |
| 16721 | return redirect(url_for("bounty", eid=eid)) |
| 16722 | |
| 16723 | conn = db_connect() |
| 16724 | exists = conn.execute("SELECT id FROM profiler_entries WHERE id=?", (eid,)).fetchone() |
| 16725 | if not exists: |
| 16726 | conn.close() |
| 16727 | flash(_("Profile not found.")) |
| 16728 | return redirect(url_for("bounty")) |
| 16729 | |
| 16730 | conn.execute( |
| 16731 | "UPDATE profiler_entries SET bounty_price=?, bounty_set_by=?, bounty_updated_at=?, bounty_reason=? WHERE id=?", |
| 16732 | (price, current_user(), now_z(), reason, eid) |
| 16733 | ) |
| 16734 | conn.commit() |
| 16735 | conn.close() |
| 16736 | flash(_("Bounty saved for profile") + f" #{eid}.") |
| 16737 | return redirect(url_for("bounty", eid=eid)) |
| 16738 | |
| 16739 | @app.route("/bounty/remove", methods=["POST"]) |
| 16740 | @login_required |
| 16741 | def bounty_remove(): |
| 16742 | """Remove a bounty from a profiler entry (admin only).""" |
| 16743 | require_admin() |
| 16744 | eid = request.form.get("eid", type=int) |
| 16745 | if not eid: |
| 16746 | flash(_("Select a profile first.")) |
| 16747 | return redirect(url_for("bounty")) |
| 16748 | |
| 16749 | conn = db_connect() |
| 16750 | exists = conn.execute("SELECT id FROM profiler_entries WHERE id=?", (eid,)).fetchone() |
| 16751 | if not exists: |
| 16752 | conn.close() |
| 16753 | flash(_("Profile not found.")) |
| 16754 | return redirect(url_for("bounty")) |
| 16755 | |
| 16756 | conn.execute( |
| 16757 | "UPDATE profiler_entries SET bounty_price=NULL, bounty_set_by=NULL, bounty_updated_at=?, bounty_reason=NULL WHERE id=?", |
| 16758 | (now_z(), eid) |
| 16759 | ) |
| 16760 | conn.commit() |
no test coverage detected