Add a maintenance pause/resume switch and a proper user navbar
RoundConfig gets a paused flag toggled via new POST /admin/pause and /admin/resume endpoints (audit-logged, surfaced as a "Manutenzione" card in the admin Parametri view). Pausing only stops the *next* round from opening once the current one closes — rounds/service.py:open_new_round_if_needed still lets an in-progress round finish, draw, and pay out its winner normally. GET /rounds/current exposes lottery_paused so the user page shows a maintenance banner (even while logged out) instead of silently going idle. Also replaces the user dashboard's stacked account-bar card + bento-grid menu with a single sticky navbar (identity row + Deposito/Bet/Prelievo tabs), and moves the page content into a dedicated .app-shell container so the navbar itself can span full width.
This commit is contained in:
1 parent
78109aa4c4
commit
162a63d04a
12 files changed
+299
-72
No files matched your search
+13
-6
@@ -19,19 +19,26 @@ async def get_active_round(session: AsyncSession) -> Round | None:
|
||||
async def open_new_round_if_needed(session: AsyncSession) -> Round | None:
|
||||
"""Returns the active round if one exists (whatever its status). Otherwise
|
||||
opens a fresh one, unless the last closed round's cooldown (ROUND_COOLDOWN_SECONDS)
|
||||
hasn't elapsed yet — in which case returns None. Callers that need to attach a
|
||||
bet must additionally check the returned round's status == "open" — a round in
|
||||
closing/drawing/paying_out isn't accepting new bets, but a new round can't open
|
||||
until it's done."""
|
||||
hasn't elapsed yet, or the lottery is paused for maintenance — in either case
|
||||
returns None. Callers that need to attach a bet must additionally check the
|
||||
returned round's status == "open" — a round in closing/drawing/paying_out
|
||||
isn't accepting new bets, but a new round can't open until it's done.
|
||||
|
||||
Pausing never touches a round already in progress: it only suppresses opening
|
||||
the *next* one, so the current round still closes, draws, and pays out the
|
||||
winner normally (see admin.py's /admin/pause and /admin/resume)."""
|
||||
active = await get_active_round(session)
|
||||
if active is not None:
|
||||
return active
|
||||
|
||||
config = await get_round_config(session)
|
||||
if config.paused:
|
||||
return None
|
||||
|
||||
last_closed = await session.scalar(select(Round).where(Round.status == "closed").order_by(Round.id.desc()))
|
||||
if last_closed is not None and last_closed.closed_at is not None:
|
||||
closed_at = last_closed.closed_at.replace(tzinfo=timezone.utc)
|
||||
cooldown_seconds = (await get_round_config(session)).round_cooldown_seconds
|
||||
if datetime.now(timezone.utc) < closed_at + timedelta(seconds=cooldown_seconds):
|
||||
if datetime.now(timezone.utc) < closed_at + timedelta(seconds=config.round_cooldown_seconds):
|
||||
return None
|
||||
|
||||
round_ = Round(status="open")
|
||||
|
||||
Reference in new issue
Block a user