feat: add per-event badge editor, pretix company import, smart guides

Badge Designer (admin): per-event WYSIWYG badge/PDF layout editor with mm canvas, text/QR/image elements, multi-select, Word+PowerPoint alignment, PowerPoint-style smart guides with snapping, Delete-key, preview and JSON views. Migration 20261015194531_badge_editor (badge_layouts + admin-only save/set-default/delete RPCs).

Company import: migration 20261015200719_events_company adds events.company; the sidecar pretix sync now fetches the organizer display name and stores it (best-effort). Bindable on badges as Company/organizer.

Tests: 15 SQL rollback assertions + 13 mocked browser tests. Docs synced.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-10-15 22:25:15 +02:00
1 parent 4ec03410ff
commit 5cb67afb5e
16 files changed
+1914 -9

No files matched your search

+4 -1
View File
@@ -95,13 +95,16 @@ A separate desktop-first React app for organizers, guarded to existing contacts
with **`is_admin`** or an **`@appe.at`** email. See [frontend/admin-app.md](./frontend/admin-app.md):
- **Views** — Dashboard (active event + aggregates), Contacts, Registrations,
Sponsors, Schedule (slots/sessions/speakers/material), Activity (manual event
and session AI summaries), Raffle (attendee prize draws), Events, Interfaces,
and session AI summaries), Raffle (attendee prize draws), Badges (per-event
WYSIWYG badge layout editor), Events, Interfaces,
Reports and Settings.
- **Auth guard** — email-only magic links; non-admin sessions are rejected.
- **Key RPCs** — `reset_registration_qr_token` (regenerate a registration's
lanyard token + sync the Auth password), `adjust_points`, `upsert_contact`,
`create_registration`, `set_registration_type`, `set_session_material`, and the
raffle functions `get_raffle_pool` / `draw_raffle_winner` / `reset_raffle`
and the badge-layout functions `save_badge_layout` / `set_default_badge_layout`
/ `delete_badge_layout`
(see [backend/rpcs.md](./backend/rpcs.md)). The deprecated AI stub is no longer
client-callable; generation uses authenticated [sidecar routes](./backend/feedback-ai.md).
+31
View File
@@ -419,6 +419,37 @@ admin-readable via RLS. All three functions are `security definer` with an empty
`search_path`, revoke execution from `PUBLIC` / `anon`, and grant it back only to
`authenticated` (the admin check is enforced inside each function).
## Badge editor
Source: [20261015194531_badge_editor.sql](../../supabase/migrations/20261015194531_badge_editor.sql).
The admin **Badges** view is a per-event WYSIWYG badge / PDF layout editor
(modelled on pretix's "PDF Editor / Badge layout"). Each event owns one or more
named **layouts** in `badge_layouts`: a page size in millimetres plus an ordered
`elements` JSON array (text boxes, QR codes, images) with mm-based geometry, so
the on-screen canvas maps 1:1 to print. Text/QR elements bind to attendee fields
(`attendee_name`, `email`, `ticket_type`, `qr_token`, `event_name`, `company`, …)
and are previewed against a real sample registration. The `company` field reads
`events.company` (the Pretix organizer name — see
[sidecar.md](./sidecar.md#pretix-sync)).
- `save_badge_layout(p_event_id, p_name, p_page_width_mm, p_page_height_mm, p_elements, p_is_default)`
→ `badge_layouts` row — **admin-only.** Upserts the layout matched on
`(event_id, name)`. When `p_is_default` is true, every other layout for the
event is demoted first, so the "one default per event" invariant holds
transactionally. Rejects blank names and non-array `elements`.
- `set_default_badge_layout(p_id)` → `void` — **admin-only.** Promotes one layout
to the event's default and demotes the previous one.
- `delete_badge_layout(p_id)` → `void` — **admin-only.** Removes a layout; the
default may not be deleted while other layouts exist (a usable default must
remain).
`badge_layouts` cascades on event deletion, is admin-readable via RLS
(`badge_layouts_admin_read`), and has a partial unique index enforcing a single
default per event. All three functions are `security definer` with an empty
`search_path`, revoke execution from `PUBLIC` / `anon`, and grant it back only to
`authenticated` (the admin check is enforced inside each function).
## Error handling
RPCs raise Postgres exceptions with human-readable messages (e.g. `you cannot
+1
View File
@@ -71,6 +71,7 @@ queries everything for the active event and handles "no active event" gracefully
| `name` | `text` | e.g. "APPE 2026" |
| `start_date` / `end_date` | `date` | |
| `location` | `text` | nullable |
| `company` | `text` | nullable — the owning organisation / company (e.g. the **Pretix organizer name**). Auto-filled by the Pretix sync; bindable on badges (see [sidecar.md](./sidecar.md)) |
| `is_active` | `boolean` | default `false` |
| `avg_feedback` | `numeric` | maintained aggregate |
| `num_sessions` | `integer` | maintained aggregate |
+26
View File
@@ -1,3 +1,29 @@
# Badge Editor Regression
After applying `20261015194531_badge_editor`, run:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/badge_layout_tests.sql
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- badge-editor.spec.ts --project=chromium
```
The SQL fixture is rollback-only: fifteen assertions cover creating a default
layout, upserting the same `(event_id, name)` in place, the one-default-per-event
invariant when a new default is saved, per-event scoping, `set_default`
promote/demote, refusing to delete the default while other layouts exist,
deleting a non-default layout, rejecting blank names, and admin/non-admin/anon
authorization (the non-admin read check runs as the real `authenticated` role so
RLS is enforced). The browser suite is API-mocked and covers loading the default
layout onto the millimetre canvas with a bound attendee name, adding/selecting a
text element and its handles, editing `x` to move an element, saving via
`save_badge_layout`, preview mode hiding the handles, the JSON view, a failed
save, the mobile layout, the **Delete key** removing the selection, binding the
**company / organizer** field, **align-centre** on the page, and **Shift-click
multi-select** for group alignment. No real attendee data changes.
See [RPC rules](./rpcs.md#badge-editor) and the [Badges view](../frontend/admin-app.md).
# Raffle Regression
After applying `20261015180640_raffle`, run:
+1
View File
@@ -21,6 +21,7 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
| **Schedule** | Slots (with a **type optionset** — `Session` / `Service Session`) + sessions (with speakers 1:N via a **multi-select search dropdown**, material upload with a **submitted / not submitted** state and `average_feedback`), plus an admin-only **Delete current schedule** action for the active event. |
| **Activity** | Tables of check-ins, connections, and feedback (per active event), with manual **Generate AI Summary** controls for the event and individual sessions. |
| **Raffle** | Draws eligible attendees one at a time for the active event. Configure the number of picks (default 5), then **Spin** a roulette that decelerates onto a server-chosen winner; repeat until the pick count is reached. Excludes staff/Admin and the leaderboard top 3, and no one can win twice in a run. **New run** clears the current winners. See [../backend/rpcs.md#raffle](../backend/rpcs.md#raffle). |
| **Badges** | A **per-event WYSIWYG badge / PDF layout editor** (modelled on pretix's PDF Editor). Pick the event, then design one or more named **layouts** (a **Default** per event, switchable / creatable / deletable). Add **text boxes**, **QR codes** and **images** to a millimetre canvas; drag to move, use the 8 resize handles + rotation handle, **Shift-click to multi-select**, and **press `Del`** to remove. While dragging, **PowerPoint-style smart guides** appear — dashed alignment lines (edges / centres, page and neighbouring items) plus equal-spacing lines — and the element **snaps** to them. A **Word-style align** toolbar (left / center / right, top / middle / bottom) plus **PowerPoint-style** object alignment — align to the **page** or to the **selection**, and **distribute** horizontally / vertically — with the same controls in the properties panel. Text binds to attendee fields (name, email, ticket type, QR token, event name, **company / organizer**, or static) with font, size, line-height, colour, bold/italic, alignment and case transform; QR binds to the token / check-in URL / email / name / static. **Undo/redo**, a **Preview** mode (no handles), a **JSON** view of the layout, and **Save**. Previewed against a real sample registration. See [../backend/rpcs.md#badge-editor](../backend/rpcs.md#badge-editor). |
| **Settings** | Global LLM endpoint, model and optional API key for feedback summaries. |
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint** + the **Real-time clock** toggle (on = the attendee app uses the real system clock for Live/Next/Done; off = the simulated mid-event clock, the default). Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
| **Interfaces** | Manages the Sessionize sync **sidecar**: status (online / running / last run), a **Run sync** control (event picker + blocking run + result modal), an **Import Excel** control (upload the Sessionize "Sessions and speakers (advanced)" `.xlsx` + a "How to get this file" tooltip), and a **Recent runs** table from `sync_runs`. See [../backend/sidecar.md](../backend/sidecar.md). |