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:
2026-03-06 00:08:15 -08:00
parent f645d78c83
commit ff9a863393
18 changed files with 768 additions and 108 deletions

View File

@@ -14,6 +14,7 @@ from app.models.subject import Subject # noqa: F401 — needed for selectinload
from app.models.session import DailySession, TimerEvent
from app.models.user import User
from app.schemas.session import DailySessionOut, SessionStart, TimerAction
from sqlalchemy import delete as sql_delete
from app.utils.timer import compute_block_elapsed, compute_break_elapsed
from app.websocket.manager import manager
@@ -194,12 +195,15 @@ async def timer_action(
# When break starts, implicitly pause the main block timer so elapsed
# time is captured accurately in the activity log and on page reload.
# Only write the pause if the block is actually running.
if body.event_type == "break_start" and block_id:
db.add(TimerEvent(
session_id=session.id,
block_id=block_id,
event_type="pause",
))
_, already_paused = await compute_block_elapsed(db, session.id, block_id)
if not already_paused:
db.add(TimerEvent(
session_id=session.id,
block_id=block_id,
event_type="pause",
))
db.add(TimerEvent(
session_id=session.id,
@@ -235,32 +239,48 @@ async def timer_action(
if body.event_type in ("start", "select", "reset") and body.block_id is not None:
prev_block_id = session.current_block_id
if prev_block_id and prev_block_id != body.block_id:
db.add(TimerEvent(
session_id=session.id,
block_id=prev_block_id,
event_type="pause",
))
# Autoflush means the implicit pause above is visible to the helper.
prev_block_elapsed_seconds, _ = await compute_block_elapsed(
prev_block_elapsed_seconds, prev_already_paused = await compute_block_elapsed(
db, session.id, prev_block_id
)
# Only write an implicit pause if the previous block was actually running.
if not prev_already_paused:
db.add(TimerEvent(
session_id=session.id,
block_id=prev_block_id,
event_type="pause",
))
# Recompute elapsed now that the pause event is included.
prev_block_elapsed_seconds, _ = await compute_block_elapsed(
db, session.id, prev_block_id
)
# Update current block if provided
if body.block_id is not None:
session.current_block_id = body.block_id
# Record the timer event
# Record the timer event (select events are not persisted — they only drive WS broadcasts)
event = TimerEvent(
session_id=session.id,
block_id=body.block_id or session.current_block_id,
event_type=body.event_type,
)
db.add(event)
if body.event_type != "select":
db.add(event)
# Mark session complete if event is session-level complete
if body.event_type == "complete" and body.block_id is None:
session.is_active = False
# Reset removes completed status — delete any complete events for this block
if body.event_type == "reset" and event.block_id:
await db.execute(
sql_delete(TimerEvent).where(
TimerEvent.session_id == session.id,
TimerEvent.block_id == event.block_id,
TimerEvent.event_type == "complete",
)
)
await db.commit()
await db.refresh(session)
@@ -283,6 +303,7 @@ async def timer_action(
"block_elapsed_seconds": block_elapsed_seconds,
"prev_block_id": prev_block_id,
"prev_block_elapsed_seconds": prev_block_elapsed_seconds,
"uncomplete_block_id": event.block_id if body.event_type == "reset" else None,
}
await manager.broadcast(session.child_id, ws_payload)