fix(admin): per-row check-in toggle; feat(db): front-desk gate + badge copies
Registrations table felt buggy because both row actions did setBusy(true) -> write -> reloadRegistrations() -> setBusy(false): the list is sorted by points, so a reload made the row you just touched jump (or vanish under a Checked-in filter), and the single `busy` flag disabled every control in the table for the whole request. The fix is per-row in-flight state (busyIds + withRowBusy) and no reload at all: the toggle patches its own row's checked_in plus the points delta the RPC returns, the type change patches `type`; a rejected write rolls both back. Only the touched row is disabled, shows a "Saving…" pulse, and two rows can save at once. Toggle hit area is now 40x41 px with a focus-visible ring. Front-desk gate: checkin_attendee reads registrations.checked_in and raises "This attendee needs to be checked in at the front desk first." when it is not true, and no longer sets checked_in as a side effect. checkins has no INSERT policy, so the RPC is the only write path and the gate cannot be bypassed. The scanner shows a dedicated "Not checked in yet" sheet instead of a toast. Badge copies: events.badge_copies (1..4, default 1). welcome_checkin sends that many pgmq jobs in one transaction (the Pi prints one label per job, so N jobs = N labels; no worker change) and clamps the value again itself. preview_welcome_checkin gained a `copies` column (drop + recreate) so the popup states the real count. Manual reprint still prints exactly one. Set from Settings -> Badge printing (active event) and the Events form, always as a single-column update; the Settings badge section now renders even when the LLM settings call fails. Tests: badge_print 113 (+6), leaderboard 47 (+1), new registration-checkin-toggle (6), front-desk-gate (3), welcome-badge-copies (3); the stale registrations-PATCH mock in registration-ticket-merge now targets set_registration_checked_in, the ambiguous Save button is "Save copies", and the print-copy assertion tolerates the typographic apostrophe. Docs updated (rpcs, schema, printing, tests, admin-app, screens) with a release record; NOT deployed - see docs/releases/2026-10-19.md.
This commit is contained in:
1 parent
c857204cfe
commit
c49a94fe80
27 files changed
+1378
-73
No files matched your search
+38
-2
@@ -124,6 +124,14 @@ Staff checks an attendee into a session.
|
||||
- **Role check:** `is_staff_or_admin()` (i.e. `is_admin()`) or it raises
|
||||
`staff or admin only`.
|
||||
- Resolves the attendee by `qr_token`.
|
||||
- **Front-desk gate:** when the attendee's `registrations.checked_in` is not
|
||||
`true`, it raises `This attendee needs to be checked in at the front desk
|
||||
first.` Nobody can be checked into a session before the **welcome** check-in at
|
||||
the front desk has marked them present at the event. The scanner shows this as
|
||||
its own sheet instead of a generic error (see
|
||||
[../frontend/screens.md](../frontend/screens.md)). `checkin_attendee` also
|
||||
stopped setting `checked_in = true` as a side effect — the welcome check-in
|
||||
(or an admin's Registrations toggle) is now the only way to earn it.
|
||||
- **Service-session guard:** if the session's slot is a `service_session`, it
|
||||
raises `service sessions cannot be checked in` (there's nothing to check into —
|
||||
everyone is in the room).
|
||||
@@ -148,9 +156,13 @@ from `checkin_attendee`, which checks someone into a specific session).
|
||||
check-in's job).
|
||||
- `already` is `true` if the attendee was already checked in to the event.
|
||||
- On a **first** check-in (and only when the event has a badge layout), enqueues
|
||||
a `badge_print` job in the same transaction (see [printing.md](printing.md)).
|
||||
`events.badge_copies` identical `badge_print` jobs in the same transaction — the
|
||||
Pi worker prints exactly one label per job, so N jobs = N labels (see
|
||||
[printing.md](printing.md)). The value is clamped to `1..4` inside the function,
|
||||
so a bad row can never flood the queue. A re-check-in (`already`) enqueues
|
||||
nothing. Manual reprint (`enqueue_badge_print`) still prints **one** label.
|
||||
|
||||
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print)`
|
||||
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print, copies)`
|
||||
Read-only preview shown by the staff scanner **before** a welcome check-in is
|
||||
committed, so the confirmation popup can name the attendee and be honest about
|
||||
printing.
|
||||
@@ -161,6 +173,10 @@ printing.
|
||||
- `will_print` is `true` only for a genuine first check-in **and** when the
|
||||
event has a badge layout with elements — exactly the condition under which
|
||||
`welcome_checkin` enqueues a job.
|
||||
- `copies` is the number of labels a confirm would queue — the same
|
||||
clamp `welcome_checkin` applies, and `0` when nothing would print. The popup
|
||||
uses it to say "print their badge 3 times" instead of a fixed "this person's
|
||||
label", so it can never over- or under-promise.
|
||||
- Checks nobody in and enqueues nothing; it is a pure lookup.
|
||||
|
||||
### `merge_tickets(p_source_id, p_target_id)` -> `jsonb`
|
||||
@@ -507,6 +523,26 @@ genuine **first** check-in it enqueues the badge job in the same transaction
|
||||
when the event has a layout with elements (see
|
||||
[welcome_checkin](#welcome_checkinp_attendee_qr--attendee_email-attendee_name-already).
|
||||
|
||||
## Front-desk gate and badge copies
|
||||
|
||||
Source of truth:
|
||||
[`supabase/migrations/20261019110000_front_desk_gate_and_badge_copies.sql`](../../supabase/migrations/20261019110000_front_desk_gate_and_badge_copies.sql)
|
||||
(see [release record](../releases/2026-10-19.md)).
|
||||
|
||||
- `events.badge_copies` — new `integer not null default 1` with
|
||||
`check (badge_copies between 1 and 4)`. Admins edit it from **Settings → Badge
|
||||
printing** for the active event, and when creating/editing an event (see
|
||||
[../frontend/admin-app.md](../frontend/admin-app.md)).
|
||||
- `checkin_attendee` re-creates: adds the **front-desk gate** and drops the
|
||||
`checked_in = true` side effect.
|
||||
- `welcome_checkin` re-creates: enqueues `badge_copies` jobs instead of one.
|
||||
- `preview_welcome_checkin` **drops and re-creates** (the return type gained
|
||||
`copies`, and Postgres cannot `create or replace` across a signature change);
|
||||
grants are re-applied in the same migration.
|
||||
|
||||
`checkins` has no `INSERT` policy, so `checkin_attendee` is the only write path
|
||||
for session check-ins — the gate cannot be bypassed from the API.
|
||||
|
||||
## Error handling
|
||||
|
||||
RPCs raise Postgres exceptions with human-readable messages (e.g. `you cannot
|
||||
|
||||
Reference in new issue
Block a user