diff --git a/.gitignore b/.gitignore index 0f6e052..3bbcfaf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .env +.env.local __pycache__/ *.pyc .venv/ diff --git a/app.py b/app.py index 701b60b..50dd9dc 100644 --- a/app.py +++ b/app.py @@ -549,8 +549,9 @@ def api_update_prompt(rid): req = get_request_by_id(rid) if not req: abort(404) - if req['status'] != 'pending': - abort(409, description='Request is no longer pending') + # Allow updates when the request is pending or when a revision has been requested. + if req['status'] not in ('pending', 'revisions_requested'): + abort(409, description='Request is no longer pending or awaiting revision') data = request.get_json(silent=True) or {} @@ -559,14 +560,17 @@ def api_update_prompt(rid): if provided_email and provided_email != req['email'].lower(): abort(400, description='Email mismatch') + # When this is a revision, keep the revision note and status as revisions_requested + # so the operator still sees it as "needs new songs", and preserve customer_approved. + new_status = 'revisions_requested' if req['status'] == 'revisions_requested' else 'prompt_ready' update_request(rid, suno_title=data.get('suno_title', '').strip(), suno_style=data.get('suno_style', '').strip(), suno_lyrics=data.get('suno_lyrics', '').strip(), - status='prompt_ready' + status=new_status ) - return jsonify({'ok': True, 'request_id': rid, 'status': 'prompt_ready'}), 200 + return jsonify({'ok': True, 'request_id': rid, 'status': new_status}), 200 @app.route('/thanks/')