Add dropdown exercise selection to Doris Barbell logs
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:09:51 +00:00
parent 6ba3fe208e
commit 3960e168bc
5 changed files with 34 additions and 4 deletions

View File

@@ -133,6 +133,7 @@ def routine_log_sheet(request: Request, routine_id: str):
'title': f"Log {routine['name']}",
'routine': routine,
'routine_sheet': _build_routine_log_sheet(routine),
'exercise_options': _exercise_options_for_routine(request, routine),
'routine_action_label': _routine_action_label(routine['name']),
'default_performed_at': _default_performed_at_value(),
},
@@ -285,6 +286,24 @@ def _build_routine_log_sheet(routine: dict) -> list[dict]:
return sheet
def _exercise_options_for_routine(request: Request, routine: dict) -> list[str]:
routine_names = [exercise['exercise_name'] for exercise in routine.get('exercises', []) if exercise.get('exercise_name')]
template_names = [
template['name']
for template in request.app.state.store.list_exercise_templates()
if template.get('name')
]
ordered = []
seen = set()
for name in [*routine_names, *template_names]:
normalized = name.strip().lower()
if normalized in seen:
continue
ordered.append(name)
seen.add(normalized)
return ordered
def _default_reps_value(target_reps: str | None) -> str:
if target_reps is None:
return ''