Some checks failed
lint.yml / chore: rebase onto upstream v1.6.1 + bump to v1.6.1-aio.1 (push) Failing after 0s
Rebases the aio fork onto upstream v1.6.1 (4bf867e), pulling in:
- fiat checkout + email/Nostr DM ticket notifications (PR #50)
- currency-conversion fix (v1.5.0)
- custom notification subject/body (v1.6.0)
- resend-email button on the ticket list (PR #51)
Notable merges:
- views_api.api_event_update keeps the explicit-field-list gating from
the aio.4 security fix, with allow_fiat + fiat_currency added so an
owner editing a fiat-enabled event keeps the fiat config.
- models.PublicEvent now exposes both upstream's fiat fields and our
location / categories / status fields.
- migrations.py reverts to byte-identical to upstream v1.6.1 (no aio
entries); fork schema lives in migrations_fork.py (per aiolabs/lnbits#8).
- Lint reformatted with black + ruff to match upstream style.
Contributors entry adds `padreug` (aio fork maintainer).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
177 lines
5.2 KiB
Python
177 lines
5.2 KiB
Python
import json
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, EmailStr, Field, root_validator, validator
|
|
|
|
|
|
class PromoCode(BaseModel):
|
|
code: str
|
|
discount_percent: float = 0.0
|
|
active: bool = True
|
|
|
|
# make the promo code uppercase
|
|
@validator("code")
|
|
def uppercase_code(cls, v):
|
|
return v.upper()
|
|
|
|
@validator("discount_percent")
|
|
def validate_discount_percent(cls, v):
|
|
assert 0 <= v <= 100, "Discount must be between 0 and 100."
|
|
return v
|
|
|
|
|
|
class EventExtra(BaseModel):
|
|
promo_codes: list[PromoCode] = Field(default_factory=list)
|
|
conditional: bool = False
|
|
min_tickets: int = 1
|
|
email_notifications: bool = False
|
|
nostr_notifications: bool = False
|
|
notification_subject: str = ""
|
|
notification_body: str = ""
|
|
|
|
|
|
class CreateEvent(BaseModel):
|
|
wallet: str | None = None # filled from caller's wallet if absent
|
|
name: str # title (required)
|
|
info: str = "" # description (optional)
|
|
closing_date: str | None = None # date-only YYYY-MM-DD; defaults to event_end_date
|
|
# ISO 8601: date-only ("2026-05-19") or datetime ("2026-05-19T18:30").
|
|
# Presence of a "T" toggles NIP-52 kind (31922 date / 31923 time).
|
|
event_start_date: str
|
|
event_end_date: str | None = None # same format as event_start_date
|
|
currency: str = "sat"
|
|
allow_fiat: bool = False
|
|
fiat_currency: str = "GBP"
|
|
amount_tickets: int = 0 # 0 = unlimited / not ticketed
|
|
price_per_ticket: float = 0 # 0 = free
|
|
banner: str | None = None
|
|
location: str | None = None # venue/address (NIP-52 'location' tag)
|
|
categories: list[str] = Field(default_factory=list) # NIP-52 't' tags
|
|
extra: EventExtra = Field(default_factory=EventExtra)
|
|
status: str = "approved" # proposed, approved, rejected
|
|
|
|
|
|
class Event(BaseModel):
|
|
id: str
|
|
wallet: str
|
|
name: str
|
|
info: str = ""
|
|
closing_date: str | None = None
|
|
canceled: bool = False
|
|
event_start_date: str
|
|
event_end_date: str | None = None
|
|
currency: str = "sat"
|
|
allow_fiat: bool = False
|
|
fiat_currency: str = "GBP"
|
|
amount_tickets: int = 0
|
|
price_per_ticket: float = 0
|
|
time: datetime
|
|
sold: int = 0
|
|
banner: str | None = None
|
|
location: str | None = None
|
|
categories: list[str] = Field(default_factory=list)
|
|
extra: EventExtra = Field(default_factory=EventExtra)
|
|
status: str = "approved"
|
|
nostr_event_id: str | None = None
|
|
nostr_event_created_at: int | None = None
|
|
|
|
@validator("categories", pre=True)
|
|
def parse_categories(cls, v):
|
|
if isinstance(v, str):
|
|
return json.loads(v) if v else []
|
|
return v or []
|
|
|
|
|
|
class PublicEvent(BaseModel):
|
|
id: str
|
|
name: str
|
|
info: str
|
|
closing_date: str | None = None
|
|
canceled: bool
|
|
event_start_date: str
|
|
event_end_date: str | None = None
|
|
currency: str
|
|
allow_fiat: bool = False
|
|
fiat_currency: str = "GBP"
|
|
price_per_ticket: float
|
|
banner: str | None
|
|
location: str | None = None
|
|
categories: list[str] = Field(default_factory=list)
|
|
extra: EventExtra = Field(default_factory=EventExtra)
|
|
status: str = "approved" # surfaces "proposed"/"rejected" so SFC can render banner
|
|
|
|
@validator("categories", pre=True)
|
|
def parse_categories(cls, v):
|
|
if isinstance(v, str):
|
|
return json.loads(v) if v else []
|
|
return v or []
|
|
|
|
|
|
class EventsSettings(BaseModel):
|
|
"""Extension-level settings for the events extension."""
|
|
|
|
auto_approve: bool = False # Skip approval workflow for non-admin users
|
|
|
|
|
|
class TicketExtra(BaseModel):
|
|
applied_promo_code: str | None = None
|
|
sats_paid: int | None = None
|
|
refund_address: str | None = None
|
|
nostr_identifier: str | None = None
|
|
ticket_base_url: str | None = None
|
|
email_notification_sent: bool = False
|
|
nostr_notification_sent: bool = False
|
|
refunded: bool = False
|
|
|
|
|
|
class CreateTicket(BaseModel):
|
|
name: str | None = None
|
|
email: EmailStr | None = None
|
|
user_id: str | None = None # LNbits user id (alternative to name+email)
|
|
promo_code: str | None = None
|
|
refund_address: str | None = None
|
|
nostr_identifier: str | None = None
|
|
payment_method: str | None = None
|
|
fiat_provider: str | None = None
|
|
|
|
@root_validator
|
|
def validate_identifiers(cls, values):
|
|
name = values.get("name")
|
|
email = values.get("email")
|
|
user_id = values.get("user_id")
|
|
if not user_id and not (name and email):
|
|
raise ValueError("Either user_id or both name and email must be provided")
|
|
if user_id and (name or email):
|
|
raise ValueError("Cannot provide both user_id and name/email")
|
|
return values
|
|
|
|
|
|
class Ticket(BaseModel):
|
|
id: str
|
|
wallet: str
|
|
event: str
|
|
name: str | None = None
|
|
email: str | None = None
|
|
user_id: str | None = None
|
|
registered: bool
|
|
paid: bool
|
|
time: datetime
|
|
reg_timestamp: datetime
|
|
extra: TicketExtra = Field(default_factory=TicketExtra)
|
|
|
|
|
|
class PublicTicket(BaseModel):
|
|
event: str
|
|
name: str | None = None
|
|
registered: bool
|
|
paid: bool
|
|
time: datetime
|
|
reg_timestamp: datetime
|
|
|
|
|
|
class TicketPaymentRequest(BaseModel):
|
|
payment_hash: str
|
|
payment_request: str | None = None
|
|
fiat_payment_request: str | None = None
|
|
fiat_provider: str | None = None
|
|
is_fiat: bool = False
|