Add HTML5 authoring change apply form
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-16 23:50:03 +03:00
parent c14db34f14
commit 460881428b
3 changed files with 133 additions and 2 deletions
+37 -1
View File
@@ -36,6 +36,7 @@ from neo4j import AsyncGraphDatabase
from pydantic import BaseModel, Field
from api_server.html5 import (
render_html5_authoring_apply_result,
render_html5_authoring_changes,
render_html5_authoring_change_detail,
render_html5_authoring_diff_result,
@@ -1809,12 +1810,47 @@ async def html5_project_authoring_semantic_diff_preview(project_id: str, request
)
try:
preview = _authoring_semantic_diff_preview(project_id, payload)
html = render_html5_authoring_diff_result(project_id, preview)
html = render_html5_authoring_diff_result(
project_id,
preview,
request_payload={
"routine_name": payload.routine_name,
"source_path": payload.source_path,
"original_text": payload.original_text,
"proposed_text": payload.proposed_text,
"task_id": payload.task_id,
"session_id": payload.session_id,
"user_id": payload.user_id,
},
)
except HTTPException as error:
html = render_html5_authoring_diff_result(project_id, error=str(error.detail))
return Response(html, media_type="text/html; charset=utf-8")
@app.post("/html5/projects/{project_id}/authoring/apply-change-set")
async def html5_project_authoring_apply_change_set(project_id: str, request: Request) -> Response:
form = await _html5_form_data(request)
payload = AuthoringApplyChangeSetRequest(
routine_name=_form_value(form, "routine_name"),
source_path=_form_value(form, "source_path"),
original_text=_form_value(form, "original_text") or "",
proposed_text=_form_value(form, "proposed_text") or "",
task_id=_form_value(form, "task_id"),
session_id=_form_value(form, "session_id"),
user_id=_form_value(form, "user_id"),
expected_next_version_id=_form_value(form, "expected_next_version_id") or "",
approved_by=_form_value(form, "approved_by") or "",
approval_note=_form_value(form, "approval_note"),
)
try:
result = await authoring_apply_change_set(project_id, payload)
html = render_html5_authoring_apply_result(project_id, result)
except HTTPException as error:
html = render_html5_authoring_apply_result(project_id, error=str(error.detail))
return Response(html, media_type="text/html; charset=utf-8")
@app.get("/html5/projects/{project_id}/setup")
async def html5_project_setup(project_id: str) -> Response:
setup = _project_setup_response(project_id)