Prefill Doris Barbell routine log timestamps
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from fastapi import APIRouter, Form, HTTPException, Request, status
|
from fastapi import APIRouter, Form, HTTPException, Request, status
|
||||||
from fastapi.responses import RedirectResponse
|
from fastapi.responses import RedirectResponse
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
@@ -132,7 +134,7 @@ def routine_log_sheet(request: Request, routine_id: str):
|
|||||||
'routine': routine,
|
'routine': routine,
|
||||||
'routine_sheet': _build_routine_log_sheet(routine),
|
'routine_sheet': _build_routine_log_sheet(routine),
|
||||||
'routine_action_label': _routine_action_label(routine['name']),
|
'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 ''
|
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:
|
def _routine_action_label(routine_name: str) -> str:
|
||||||
if ': ' in routine_name:
|
if ': ' in routine_name:
|
||||||
label = routine_name.split(': ', 1)[1].strip().lower()
|
label = routine_name.split(': ', 1)[1].strip().lower()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from fastapi.testclient import TestClient
|
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_reps"' in body
|
||||||
assert 'name="exercise_0_set_0_weight_lbs"' in body
|
assert 'name="exercise_0_set_0_weight_lbs"' in body
|
||||||
assert 'value="10"' 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:
|
def test_seeded_routine_log_submission_creates_structured_workout(tmp_path: Path) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user