Add delete-songs controls to admin request page

Operators can now select Version A and/or Version B in the Upload Songs
section and click 'Delete Selected Songs'. The handler removes the
chosen MP3 files, clears their DB paths, resets customer_approved to
'none', and sets the request status back to 'prompt_ready' so new
songs can be uploaded.

Bumps version to 0.5.1.
This commit is contained in:
Troll (Hermes Agent) 2026-08-05 20:05:20 +00:00
parent d7e54809c9
commit 7eb72e511d
4 changed files with 68 additions and 18 deletions

36
app.py
View file

@ -1126,6 +1126,42 @@ def admin_request(rid):
)
flash('Prompt saved.', 'success')
elif action == 'delete_songs':
# Remove selected uploaded MP3s and reset status so new songs can be uploaded.
to_delete = request.form.getlist('delete_song')
if not to_delete:
flash('Select at least one song to delete.', 'error')
return redirect(url_for('admin_request', rid=rid))
update_fields = {}
for version in to_delete:
if version == 'a':
path = req.get('song_a_path')
if path and Path(path).exists():
try:
Path(path).unlink()
except OSError:
pass
update_fields['song_a_path'] = None
elif version == 'b':
path = req.get('song_b_path')
if path and Path(path).exists():
try:
Path(path).unlink()
except OSError:
pass
update_fields['song_b_path'] = None
if update_fields:
# Wipe any prior customer approval because the old files are gone.
update_fields['customer_approved'] = 'none'
# Reset to prompt_ready since songs need to be uploaded again.
update_fields['status'] = 'prompt_ready'
update_request(rid, **update_fields)
flash('Selected songs deleted. Request reset to Prompt Ready.', 'success')
else:
flash('No uploaded songs selected for deletion.', 'error')
elif action == 'upload_songs':
# Save uploaded MP3 files for Version A and/or Version B.
# Use the saved Suno title as the MP3 title tag if available.