feat: add user_id ticket support and public events endpoint
Some checks failed
lint / lint (push) Has been cancelled

- Tickets can be created with user_id instead of name/email
- name/email default to empty string in DB (not NULL-safe)
- New endpoints: GET /api/v1/events/public, GET /api/v1/tickets/user/{user_id}
- POST /api/v1/tickets/{event_id} accepts user_id in body
- Migration m007 adds user_id column to tickets table
- CreateTicket validates: either user_id or (name + email) required

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-04-24 02:55:18 -04:00
commit 2740d73678
4 changed files with 105 additions and 9 deletions

View file

@ -1,7 +1,8 @@
from datetime import datetime
from typing import Optional
from fastapi import Query
from pydantic import BaseModel, EmailStr, Field, validator
from pydantic import BaseModel, EmailStr, Field, root_validator, validator
class PromoCode(BaseModel):
@ -66,18 +67,29 @@ class TicketExtra(BaseModel):
class CreateTicket(BaseModel):
name: str
email: EmailStr
name: Optional[str] = None
email: Optional[str] = None
user_id: Optional[str] = None
promo_code: str | None = None
refund_address: str | None = None
@root_validator
def validate_identifiers(cls, values):
user_id = values.get("user_id")
name = values.get("name")
email = values.get("email")
if not user_id and not (name and email):
raise ValueError("Either user_id or both name and email must be provided")
return values
class Ticket(BaseModel):
id: str
wallet: str
event: str
name: str
email: str
name: str = ""
email: str = ""
user_id: Optional[str] = None
registered: bool
paid: bool
time: datetime