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:
@@ -17,7 +17,7 @@ from app.models.schedule import ScheduleBlock
|
||||
from app.models.subject import Subject # noqa: F401 — needed for selectinload chain
|
||||
from app.models.session import DailySession, TimerEvent
|
||||
from app.schemas.session import DashboardSnapshot
|
||||
from app.utils.timer import compute_block_elapsed
|
||||
from app.utils.timer import compute_block_elapsed, compute_break_elapsed
|
||||
|
||||
router = APIRouter(prefix="/api/dashboard", tags=["dashboard"])
|
||||
|
||||
@@ -65,10 +65,34 @@ async def get_dashboard(child_id: int, db: AsyncSession = Depends(get_db)):
|
||||
|
||||
# Compute elapsed seconds and paused state for the current block from timer_events
|
||||
is_paused = False
|
||||
is_break_active = False
|
||||
break_elapsed_seconds = 0
|
||||
is_break_paused = False
|
||||
if session and session.current_block_id:
|
||||
block_elapsed_seconds, is_paused = await compute_block_elapsed(
|
||||
db, session.id, session.current_block_id
|
||||
)
|
||||
# Determine if break mode is active: check whether the most recent
|
||||
# timer event for this block (main or break) is a break event.
|
||||
last_event_result = await db.execute(
|
||||
select(TimerEvent)
|
||||
.where(
|
||||
TimerEvent.session_id == session.id,
|
||||
TimerEvent.block_id == session.current_block_id,
|
||||
TimerEvent.event_type.in_([
|
||||
"start", "resume",
|
||||
"break_start", "break_resume", "break_pause", "break_reset",
|
||||
]),
|
||||
)
|
||||
.order_by(TimerEvent.occurred_at.desc())
|
||||
.limit(1)
|
||||
)
|
||||
last_event = last_event_result.scalar_one_or_none()
|
||||
if last_event and last_event.event_type.startswith("break_"):
|
||||
is_break_active = True
|
||||
break_elapsed_seconds, is_break_paused = await compute_break_elapsed(
|
||||
db, session.id, session.current_block_id
|
||||
)
|
||||
|
||||
routine_result = await db.execute(
|
||||
select(MorningRoutineItem)
|
||||
@@ -93,4 +117,7 @@ async def get_dashboard(child_id: int, db: AsyncSession = Depends(get_db)):
|
||||
is_paused=is_paused,
|
||||
morning_routine=morning_routine,
|
||||
break_activities=break_activities,
|
||||
is_break_active=is_break_active,
|
||||
break_elapsed_seconds=break_elapsed_seconds,
|
||||
is_break_paused=is_break_paused,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user