Add Steps progress indicator to admin request page

This commit is contained in:
Troll (Hermes Agent) 2026-08-11 16:36:03 +00:00
parent 1eae83baaa
commit de7e99b6ae
2 changed files with 121 additions and 2 deletions

38
app.py
View file

@ -96,6 +96,33 @@ STATUS_LABELS = {
'cancelled': 'Cancelled',
}
def get_request_steps(req):
"""
Return a linear step sequence and the current step index for the request lifecycle.
Steps follow the standard flow: Pending -> Prompt Ready -> Songs Ready -> Approved -> Delivered.
Special statuses like 'revisions_requested' and 'paid' are mapped to the closest visible step.
Cancelled requests are returned with index -1 so the UI can render a cancelled state.
"""
steps = [
('pending', 'Pending'),
('prompt_ready', 'Prompt Ready'),
('songs_uploaded', 'Songs Ready'),
('awaiting_payment', 'Approved'),
('delivered', 'Delivered'),
]
status = req.get('status', 'pending')
if status == 'cancelled':
return steps, -1
if status == 'revisions_requested':
return steps, 2 # still at Songs Ready visually, with a revision note
if status == 'paid':
return steps, 3 # payment recorded, awaiting final delivery
for i, (key, _) in enumerate(steps):
if key == status:
return steps, i
return steps, 0
# ---------------------------------------------------------------------------
# Public customer routes
# ---------------------------------------------------------------------------
@ -1229,8 +1256,14 @@ def admin_request(rid):
except Exception as e:
flash(f'Payment recorded, but delivery email failed: {e}', 'error')
steps, current_step = get_request_steps(req)
musicgpt_status = req.get('musicgpt_status')
return redirect(url_for('admin_request', rid=rid))
steps, current_step = get_request_steps(req)
musicgpt_status = req.get('musicgpt_status')
return render_template(
'admin/request.html',
req=req,
@ -1246,7 +1279,10 @@ def admin_request(rid):
musicgpt_models=get_musicgpt_models(),
musicgpt_default_model=get_musicgpt_default_model(),
format_musicgpt_cost=format_musicgpt_cost,
deliver_album_cover=load_booth_settings().get('deliver_album_cover', False)
deliver_album_cover=load_booth_settings().get('deliver_album_cover', False),
steps=steps,
current_step=current_step,
musicgpt_status=musicgpt_status,
)