feat(versions): POST/DELETE /api/notes/:id/versions/:vid/pin
This commit is contained in:
@@ -553,6 +553,39 @@ async def get_version_route(note_id: int, version_id: int):
|
|||||||
return jsonify(version.to_dict(include_body=True))
|
return jsonify(version.to_dict(include_body=True))
|
||||||
|
|
||||||
|
|
||||||
|
@notes_bp.route("/<int:note_id>/versions/<int:version_id>/pin", methods=["POST"])
|
||||||
|
@login_required
|
||||||
|
async def pin_version_route(note_id: int, version_id: int):
|
||||||
|
"""Mark a version as manually pinned. Body: {"label": str | null}."""
|
||||||
|
uid = get_current_user_id()
|
||||||
|
data = await request.get_json() or {}
|
||||||
|
label = data.get("label")
|
||||||
|
if label is not None and not isinstance(label, str):
|
||||||
|
return jsonify({"error": "label must be a string or null"}), 400
|
||||||
|
from fabledassistant.services.version_pinning import pin_version
|
||||||
|
try:
|
||||||
|
version = await pin_version(uid, note_id, version_id, label=label)
|
||||||
|
except ValueError as e:
|
||||||
|
return jsonify({"error": str(e)}), 400
|
||||||
|
if version is None:
|
||||||
|
return not_found("Version")
|
||||||
|
return jsonify(version.to_dict(include_body=False))
|
||||||
|
|
||||||
|
|
||||||
|
@notes_bp.route(
|
||||||
|
"/<int:note_id>/versions/<int:version_id>/pin", methods=["DELETE"],
|
||||||
|
)
|
||||||
|
@login_required
|
||||||
|
async def unpin_version_route(note_id: int, version_id: int):
|
||||||
|
"""Downgrade a manually-pinned version back to rolling."""
|
||||||
|
uid = get_current_user_id()
|
||||||
|
from fabledassistant.services.version_pinning import unpin_version
|
||||||
|
version = await unpin_version(uid, note_id, version_id)
|
||||||
|
if version is None:
|
||||||
|
return not_found("Version")
|
||||||
|
return jsonify(version.to_dict(include_body=False))
|
||||||
|
|
||||||
|
|
||||||
# ── Graph route ────────────────────────────────────────────────────────────────
|
# ── Graph route ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@notes_bp.route("/graph", methods=["GET"])
|
@notes_bp.route("/graph", methods=["GET"])
|
||||||
|
|||||||
Reference in New Issue
Block a user