feat: require customer approval before mark paid/deliver

- Disable checkboxes, payment ref input, and submit button in admin UI when customer has not approved.
- Add server-side guard in mark_paid_deliver action.
This commit is contained in:
Troll (Hermes Agent) 2026-08-03 19:07:22 +00:00
parent 3057eb8eda
commit d5d4882d07
2 changed files with 13 additions and 4 deletions

4
app.py
View file

@ -859,6 +859,10 @@ def admin_request(rid):
elif action == 'mark_paid_deliver': elif action == 'mark_paid_deliver':
# Finalize: record Square payment ref, attach approved MP3s, email customer. # Finalize: record Square payment ref, attach approved MP3s, email customer.
if req.get('customer_approved', 'none') == 'none':
flash('Customer must approve a version before you can mark paid or deliver.', 'error')
return redirect(url_for('admin_request', rid=rid))
payment_ref = request.form.get('square_payment_ref', '').strip() payment_ref = request.form.get('square_payment_ref', '').strip()
if not payment_ref: if not payment_ref:
flash('Square payment reference is required.', 'error') flash('Square payment reference is required.', 'error')

View file

@ -300,8 +300,9 @@
{% for fpath in files_to_show %} {% for fpath in files_to_show %}
<div class="file-select"> <div class="file-select">
<input type="checkbox" id="file_{{ loop.index }}" name="deliver_file" value="{{ fpath }}" <input type="checkbox" id="file_{{ loop.index }}" name="deliver_file" value="{{ fpath }}"
{% if fpath in all_files %}checked{% endif %}> {% if fpath in all_files %}checked{% endif %}
<label for="file_{{ loop.index }}">{{ basename(fpath) }}</label> {% if req.customer_approved == 'none' %}disabled{% endif %}>
<label for="file_{{ loop.index }}"{% if req.customer_approved == 'none' %} style="opacity:.6"{% endif %}>{{ basename(fpath) }}</label>
{% if not (fpath == req.song_a_path or fpath == req.song_b_path) %} {% if not (fpath == req.song_a_path or fpath == req.song_b_path) %}
<div class="old-rev">archived / revision file</div> <div class="old-rev">archived / revision file</div>
{% endif %} {% endif %}
@ -311,10 +312,14 @@
{% endfor %} {% endfor %}
<label for="square_payment_ref">Square Payment Reference</label> <label for="square_payment_ref">Square Payment Reference</label>
<input type="text" id="square_payment_ref" name="square_payment_ref" placeholder="e.g. sq0idp-... or receipt number"> <input type="text" id="square_payment_ref" name="square_payment_ref" placeholder="e.g. sq0idp-... or receipt number"
{% if req.customer_approved == 'none' %}disabled{% endif %}>
<div class="actions"> <div class="actions">
<button type="submit" class="success">Mark Paid & Deliver</button> <button type="submit" class="success" {% if req.customer_approved == 'none' %}disabled{% endif %}>Mark Paid & Deliver</button>
</div> </div>
{% if req.customer_approved == 'none' %}
<p style="margin-top:.5rem;color:#f87171;font-weight:600">⚠️ Customer must approve a version before you can mark paid or deliver.</p>
{% endif %}
</form> </form>
</div> </div>
</div> </div>