fix: curate swap endpoint name, reorder date field, 404 on missing asset

- Rename /curate/retag to /curate/swap; response now includes new_tag
- /curate/reorder: read body["order"] key (was ordered_ids); include date field
- /curate/remove and /curate/swap: return 404 if asset_id not found
- Update phase3.html JS fetch calls and reorder payload to match spec

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 16:37:25 +02:00
parent 851df070e4
commit 23b68d845b
2 changed files with 15 additions and 14 deletions
+12 -12
View File
@@ -28,31 +28,31 @@ def curate():
def remove():
body = request.get_json()
state = load_state(body["album_id"], current_app)
for p in state.photos:
if p.id == body["asset_id"]:
p.tag = "skip"
break
photo = next((p for p in state.photos if p.id == body["asset_id"]), None)
if photo is None:
return jsonify({"ok": False, "error": "photo not found"}), 404
photo.tag = "skip"
save_state(state, current_app)
return jsonify({"ok": True})
@bp.post("/curate/retag")
def retag():
@bp.post("/curate/swap")
def swap():
body = request.get_json()
state = load_state(body["album_id"], current_app)
for p in state.photos:
if p.id == body["asset_id"]:
p.tag = "story" if p.tag == "journal" else "journal"
break
photo = next((p for p in state.photos if p.id == body["asset_id"]), None)
if photo is None:
return jsonify({"ok": False, "error": "photo not found"}), 404
photo.tag = "story" if photo.tag == "journal" else "journal"
save_state(state, current_app)
return jsonify({"ok": True})
return jsonify({"ok": True, "new_tag": photo.tag})
@bp.post("/curate/reorder")
def reorder():
body = request.get_json()
state = load_state(body["album_id"], current_app)
order_map = {aid: i for i, aid in enumerate(body["ordered_ids"])}
order_map = {aid: i for i, aid in enumerate(body["order"])}
for p in state.photos:
if p.id in order_map:
p.order = order_map[p.id]