Add Done button, tablet controls, super admin management, midnight strike reset, and activity log improvements
- Done button snaps block to full duration, marks complete, logs "Marked Done by User"; Reset after Done fully un-completes the block - Session action buttons stretch full-width and double height for tablet tapping - Super admin: reset password, disable/enable accounts, delete user (with cascade), last active date per user's timezone - Disabled account login returns specific error message instead of generic invalid credentials - Users can change own password from Admin → Settings - Strikes reset automatically at midnight in user's configured timezone (lazy reset on page load) - Break timer state fully restored when navigating away and back to dashboard - Timer no longer auto-starts on navigation if it wasn't running before - Implicit pause guard: no duplicate pause events when switching already-paused blocks or starting a break - Block selection events removed from activity log; all event types have human-readable labels - House emoji favicon via inline SVG data URI - README updated to reflect all changes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
from datetime import datetime, timezone
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from pydantic import BaseModel, Field
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
@@ -13,6 +16,15 @@ from app.websocket.manager import manager
|
||||
router = APIRouter(prefix="/api/children", tags=["children"])
|
||||
|
||||
|
||||
def _today_in_tz(tz_name: str):
|
||||
"""Return today's date in the given IANA timezone, falling back to UTC."""
|
||||
try:
|
||||
tz = ZoneInfo(tz_name)
|
||||
except (ZoneInfoNotFoundError, Exception):
|
||||
tz = timezone.utc
|
||||
return datetime.now(tz).date()
|
||||
|
||||
|
||||
@router.get("", response_model=list[ChildOut])
|
||||
async def list_children(
|
||||
current_user: User = Depends(get_current_user),
|
||||
@@ -21,7 +33,20 @@ async def list_children(
|
||||
result = await db.execute(
|
||||
select(Child).where(Child.user_id == current_user.id).order_by(Child.name)
|
||||
)
|
||||
return result.scalars().all()
|
||||
children = result.scalars().all()
|
||||
|
||||
today = _today_in_tz(current_user.timezone)
|
||||
needs_commit = False
|
||||
for child in children:
|
||||
if child.strikes != 0 and child.strikes_last_reset != today:
|
||||
child.strikes = 0
|
||||
child.strikes_last_reset = today
|
||||
needs_commit = True
|
||||
await manager.broadcast(child.id, {"event": "strikes_update", "strikes": 0})
|
||||
if needs_commit:
|
||||
await db.commit()
|
||||
|
||||
return children
|
||||
|
||||
|
||||
@router.post("", response_model=ChildOut, status_code=status.HTTP_201_CREATED)
|
||||
|
||||
Reference in New Issue
Block a user