feat: add event approval workflow with admin UI
Non-admin event submissions now land in a "proposed" queue that LNbits
admins review before the event becomes ticketable and publicly listed.
- m008 adds events.events.status (proposed/approved/rejected); m010 seeds
an events.settings singleton row with the auto_approve toggle.
- Models: Event/CreateEvent.status, EventsSettings, optional date fields
with sensible defaults (closing_date defaults to event_end_date which
defaults to event_start_date), PublicEvent.status surfaces the workflow
state on the public endpoint.
- crud: get_all/public/pending_events for the admin views; get/update_settings
for the auto_approve toggle; create_event auto-fills missing date defaults.
- views_api:
* POST /api/v1/events accepts wallet invoice keys so anyone can submit;
handler stamps status="proposed" for non-admins when auto_approve is off
* /public, /all, /pending, /settings (GET+PUT), /{id}/{approve,reject},
/{id}/tickets endpoints; literal-prefix routes declared before /{event_id}
so FastAPI matches them correctly
* Public GET /{event_id} bypasses sold-out / closing-window gates for
proposed/rejected events and returns the trimmed PublicEvent so the SFC
can render a "pending approval" banner
* POST /tickets/{event_id} rejects when event.status != "approved"
- Frontend: index.vue gains an admin Settings card, Pending Approvals list,
status badge column and approve/reject row actions, plus an All Users'
Events admin table; index.js gains the data + methods + an isAdmin probe
via GET /events/all; display.vue shows pending/rejected banners and
hides the Buy Ticket form unless status === "approved".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
11043ec8a7
commit
4c8e06a6a9
7 changed files with 526 additions and 51 deletions
|
|
@ -200,3 +200,35 @@ async def m007_add_user_id_support(db):
|
|||
await _alter_add_column_safe(
|
||||
db, "ALTER TABLE events.ticket ADD COLUMN user_id TEXT"
|
||||
)
|
||||
|
||||
|
||||
async def m008_add_event_status(db):
|
||||
"""
|
||||
Add status column to events table for the proposal/approval workflow.
|
||||
Values: 'proposed', 'approved', 'rejected'. Existing rows default to
|
||||
'approved' so they stay visible after upgrade.
|
||||
"""
|
||||
await _alter_add_column_safe(
|
||||
db,
|
||||
"ALTER TABLE events.events ADD COLUMN status TEXT NOT NULL DEFAULT 'approved'",
|
||||
)
|
||||
|
||||
|
||||
async def m010_add_events_settings(db):
|
||||
"""
|
||||
Create the extension settings singleton row used by the admin UI to
|
||||
toggle e.g. auto_approve.
|
||||
"""
|
||||
await db.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS events.settings (
|
||||
id INTEGER PRIMARY KEY DEFAULT 1,
|
||||
auto_approve BOOLEAN NOT NULL DEFAULT FALSE
|
||||
)
|
||||
"""
|
||||
)
|
||||
await db.execute(
|
||||
"INSERT INTO events.settings (id, auto_approve) "
|
||||
"SELECT 1, FALSE WHERE NOT EXISTS "
|
||||
"(SELECT 1 FROM events.settings WHERE id = 1)"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue