From 92b4f53505d53da2e5a163d5bb94dc7ef75b27ae Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 17 Sep 2024 15:21:57 +0300 Subject: Update "POST /wiki/comment_id/edit" to have RDF edits. * gn3/api/metadata_api/wiki.py: Import update_wiki_comment. (edit_wiki): Update wiki in RDF. Signed-off-by: Munyoki Kilyungi --- gn3/api/metadata_api/wiki.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gn3/api/metadata_api/wiki.py b/gn3/api/metadata_api/wiki.py index 0b91ce0..7595993 100644 --- a/gn3/api/metadata_api/wiki.py +++ b/gn3/api/metadata_api/wiki.py @@ -8,8 +8,11 @@ from flask import Blueprint, request, jsonify, current_app, make_response from gn3 import db_utils from gn3.auth.authorisation.oauth2.resource_server import require_oauth from gn3.db import wiki -from gn3.db.rdf.wiki import (get_wiki_entries_by_symbol, - get_comment_history) +from gn3.db.rdf.wiki import ( + get_wiki_entries_by_symbol, + get_comment_history, + update_wiki_comment, +) wiki_blueprint = Blueprint("wiki", __name__, url_prefix="wiki") @@ -68,6 +71,18 @@ def edit_wiki(comment_id: int): category_addition_query, (comment_id, insert_dict["versionId"], cat_id) ) + + # Editing RDF: + update_wiki_comment( + comment_id=comment_id, + payload=payload, + sparql_conf={ + "sparql_uri": current_app.config["SPARQL_ENDPOINT"], + "sparql_user": current_app.config["SPARQL_USER"], + "sparql_password": current_app.config["SPARQL_PASSWORD"], + "sparql_auth_uri": current_app.config["SPARQL_AUTH_URI"], + }, + ) return jsonify({"success": "ok"}) return jsonify(error="Error editing wiki entry, most likely due to DB error!"), 500 -- cgit v1.2.3