Prefill Doris Barbell routine log timestamps
Some checks failed
secret-guardrails / artifact-secret-scan (push) Has been cancelled
secret-guardrails / gitleaks (push) Has been cancelled

This commit is contained in:
Fizzlepoof
2026-05-28 18:05:54 +00:00
parent 8a61169ab9
commit 6ba3fe208e
2 changed files with 9 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
from __future__ import annotations
from datetime import datetime
from fastapi import APIRouter, Form, HTTPException, Request, status
from fastapi.responses import RedirectResponse
from fastapi.templating import Jinja2Templates
@@ -132,7 +134,7 @@ def routine_log_sheet(request: Request, routine_id: str):
'routine': routine,
'routine_sheet': _build_routine_log_sheet(routine),
'routine_action_label': _routine_action_label(routine['name']),
'default_performed_at': '',
'default_performed_at': _default_performed_at_value(),
},
)
@@ -290,6 +292,10 @@ def _default_reps_value(target_reps: str | None) -> str:
return cleaned if cleaned.isdigit() else ''
def _default_performed_at_value() -> str:
return datetime.now().astimezone().strftime('%Y-%m-%dT%H:%M')
def _routine_action_label(routine_name: str) -> str:
if ': ' in routine_name:
label = routine_name.split(': ', 1)[1].strip().lower()

View File

@@ -1,4 +1,5 @@
import json
import re
from pathlib import Path
from fastapi.testclient import TestClient
@@ -390,6 +391,7 @@ def test_seeded_routine_can_render_prefilled_log_sheet(tmp_path: Path) -> None:
assert 'name="exercise_0_set_0_reps"' in body
assert 'name="exercise_0_set_0_weight_lbs"' in body
assert 'value="10"' in body
assert re.search(r'name="performed_at" value="\d{4}-\d{2}-\d{2}T\d{2}:\d{2}"', body)
def test_seeded_routine_log_submission_creates_structured_workout(tmp_path: Path) -> None: