Add user bug reporting with admin triage (open/read/resolved)
Turns the /report-bug placeholder into a real form (POST /bug-reports, optionally attributed to the logged-in user) and adds a "Segnalazioni bug" section to /admin to view and triage them. A logged-in reporter can also check their own report's status via GET /bug-reports/mine, since anonymous submissions have no user to show a history to. Status is a three-state lifecycle (open -> read -> resolved) rather than a plain boolean, so an admin can acknowledge a report distinctly from actually fixing it. The schema went through two migrations because the first one (add bug_reports table) had already been applied against the running instance with a `resolved` boolean before the three-state design was decided, so a follow-up migration backfills it into `status` instead of rewriting already-applied history. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -188,6 +188,24 @@ class Withdrawal(Base):
|
||||
confirmed_at: Mapped[datetime | None] = mapped_column(default=None)
|
||||
|
||||
|
||||
class BugReport(Base):
|
||||
__tablename__ = "bug_reports"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
description: Mapped[str] = mapped_column(Text)
|
||||
contact: Mapped[str | None] = mapped_column(String(256), default=None)
|
||||
# Set when the reporter was logged in at submission time; the report page is
|
||||
# reachable both logged-in and logged-out (like GET /rounds/current), so this
|
||||
# stays nullable rather than requiring auth just to file a report.
|
||||
user_id: Mapped[int | None] = mapped_column(ForeignKey("users.id"), default=None)
|
||||
# open -> read -> resolved, admin-driven (app/api/routes/admin.py). "read" is a
|
||||
# distinct step from "resolved" so a reporter checking their own status (only
|
||||
# possible when logged in — see GET /bug-reports/mine) can tell "an admin has
|
||||
# seen this" apart from "this has actually been fixed".
|
||||
status: Mapped[str] = mapped_column(String(16), default="open")
|
||||
created_at: Mapped[datetime] = mapped_column(default=utcnow)
|
||||
|
||||
|
||||
class AuditLog(Base):
|
||||
__tablename__ = "audit_log"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user