aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-09-17 19:54:03 +0300
committerJohn Nduli Kilyungi2024-09-18 08:32:34 +0300
commit7e6cd434ceebc10d0c61d8d93a351a512ed74108 (patch)
treecc3b3d0913ea34ddcc9a9b9b1ec23bc7a16bcfc7 /gn3/api
parent32be08bebb6d43c6e446dec12526cd912727c6fb (diff)
downloadgenenetwork3-7e6cd434ceebc10d0c61d8d93a351a512ed74108.tar.gz
Pass in insert_dict instead of payload in "get_wiki_entries".
* gn3/api/metadata_api/wiki.py (edit_wiki) [insert_dict]: Add species, categories fields. [update_wiki_comment]: Pass in insert_dict, and get rid of redundant keys. Directly pass in sparql_auth's conf params instead of a dict. * gn3/db/rdf/wiki.py (get_next_comment_version): Get rid of redundant params. Use fields directly from insert_dict. Directly pass in sparql_auth's conf params instead of a dict. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/metadata_api/wiki.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/gn3/api/metadata_api/wiki.py b/gn3/api/metadata_api/wiki.py
index 8aa0b37..70045aa 100644
--- a/gn3/api/metadata_api/wiki.py
+++ b/gn3/api/metadata_api/wiki.py
@@ -25,20 +25,21 @@ def edit_wiki(comment_id: int):
# FIXME: attempt to check and fix for types here with relevant errors
payload: Dict[str, Any] = request.json # type: ignore
pubmed_ids = [str(x) for x in payload.get("pubmed_ids", [])]
- created = datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
insert_dict = {
"Id": comment_id,
"symbol": payload["symbol"],
"PubMed_ID": " ".join(pubmed_ids),
"comment": payload["comment"],
"email": payload["email"],
- "createtime": created,
+ "createtime": datetime.datetime.now(datetime.timezone.utc).strftime(
+ "%Y-%m-%d %H:%M:%S"
+ ),
"user_ip": request.environ.get("HTTP_X_REAL_IP", request.remote_addr),
"weburl": payload.get("web_url"),
"initial": payload.get("initial"),
"reason": payload["reason"],
+ "species": payload["species"],
+ "categories": payload["categories"],
}
insert_query = """
@@ -76,14 +77,10 @@ def edit_wiki(comment_id: int):
# Editing RDF:
update_wiki_comment(
comment_id=comment_id,
- payload=payload,
- next_version=next_version,
- created=created,
- sparql_conf={
- "sparql_user": current_app.config["SPARQL_USER"],
- "sparql_password": current_app.config["SPARQL_PASSWORD"],
- "sparql_auth_uri": current_app.config["SPARQL_AUTH_URI"],
- },
+ insert_dict=insert_dict,
+ 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