feat: add admin-toggleable auto-approve setting
Some checks failed
lint.yml / feat: add admin-toggleable auto-approve setting (pull_request) Failing after 0s
Some checks failed
lint.yml / feat: add admin-toggleable auto-approve setting (pull_request) Failing after 0s
- Extension settings table with auto_approve boolean - GET/PUT /api/v1/settings endpoints (LNbits admin only) - Settings card in admin UI with toggle - When auto_approve is enabled, non-admin events skip approval Closes aiolabs/events#11 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2db0102857
commit
d69ec7dda2
6 changed files with 116 additions and 4 deletions
23
crud.py
23
crud.py
|
|
@ -5,7 +5,7 @@ from typing import Optional
|
|||
from lnbits.db import Database
|
||||
from lnbits.helpers import urlsafe_short_hash
|
||||
|
||||
from .models import CreateEvent, Event, Ticket, TicketExtra
|
||||
from .models import CreateEvent, Event, EventsSettings, Ticket, TicketExtra
|
||||
|
||||
|
||||
def _parse_ticket_row(row) -> dict:
|
||||
|
|
@ -220,6 +220,27 @@ async def get_pending_events() -> list[Event]:
|
|||
)
|
||||
|
||||
|
||||
async def get_settings() -> EventsSettings:
|
||||
"""Get extension settings (single row, always exists after migration)."""
|
||||
row = await db.fetchone("SELECT * FROM events.settings WHERE id = 1")
|
||||
if row:
|
||||
return EventsSettings(**dict(row))
|
||||
return EventsSettings()
|
||||
|
||||
|
||||
async def update_settings(settings: EventsSettings) -> EventsSettings:
|
||||
"""Update extension settings."""
|
||||
await db.execute(
|
||||
"""
|
||||
UPDATE events.settings
|
||||
SET auto_approve = :auto_approve
|
||||
WHERE id = 1
|
||||
""",
|
||||
{"auto_approve": settings.auto_approve},
|
||||
)
|
||||
return settings
|
||||
|
||||
|
||||
async def delete_event(event_id: str) -> None:
|
||||
await db.execute("DELETE FROM events.events WHERE id = :id", {"id": event_id})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue