feat: Phase 3 curate with remove, retag, drag reorder
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
from flask import Blueprint, current_app, jsonify, render_template, request
|
||||
from app.state import load_state, save_state
|
||||
|
||||
bp = Blueprint("curate", __name__)
|
||||
|
||||
|
||||
@bp.get("/curate")
|
||||
def curate():
|
||||
album_id = request.args["album_id"]
|
||||
state = load_state(album_id, current_app)
|
||||
kept = [p for p in state.photos if p.tag in ("journal", "story")]
|
||||
photos_by_day = {}
|
||||
for p in kept:
|
||||
day = p.local_datetime[:10]
|
||||
photos_by_day.setdefault(day, []).append(p)
|
||||
return render_template(
|
||||
"phase3.html",
|
||||
state=state,
|
||||
photos_by_day=photos_by_day,
|
||||
current_phase="curate",
|
||||
album_id=album_id,
|
||||
phase_stale=state.phase_stale,
|
||||
notes_content=state.notes,
|
||||
)
|
||||
|
||||
|
||||
@bp.post("/curate/remove")
|
||||
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
|
||||
save_state(state, current_app)
|
||||
return jsonify({"ok": True})
|
||||
|
||||
|
||||
@bp.post("/curate/retag")
|
||||
def retag():
|
||||
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
|
||||
save_state(state, current_app)
|
||||
return jsonify({"ok": True})
|
||||
|
||||
|
||||
@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"])}
|
||||
for p in state.photos:
|
||||
if p.id in order_map:
|
||||
p.order = order_map[p.id]
|
||||
save_state(state, current_app)
|
||||
return jsonify({"ok": True})
|
||||
|
||||
|
||||
@bp.post("/curate/done")
|
||||
def done():
|
||||
body = request.get_json()
|
||||
state = load_state(body["album_id"], current_app)
|
||||
if "curate" not in state.phases_completed:
|
||||
state.phases_completed.append("curate")
|
||||
state.phase = "group"
|
||||
save_state(state, current_app)
|
||||
return jsonify({"ok": True, "redirect": f"/group?album_id={body['album_id']}"})
|
||||
Reference in New Issue
Block a user