From 77f12fb59c4277e2bd51f8dba78518172bca1735 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 20 May 2022 11:27:17 +0300 Subject: Replace "_get_author" with "gn3.authentication.get_user_info_by_key" * wqflask/wqflask/metadata_edits.py (_get_author): Delete function. (show_case_attribute_columns): Use "get_user_info_by_key". --- wqflask/wqflask/metadata_edits.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index dcadcc99..a13cadf8 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -26,6 +26,7 @@ from wqflask.decorators import login_required from gn3.authentication import AdminRole from gn3.authentication import get_highest_user_access_role +from gn3.authentication import get_user_info_by_key from gn3.csvcmp import create_dirs_if_not_exists from gn3.csvcmp import csv_diff from gn3.csvcmp import extract_invalid_csv_headers @@ -51,14 +52,6 @@ from gn3.db.sample_data import get_case_attributes metadata_edit = Blueprint("metadata_edit", __name__) -def _get_author(author: str) -> str: - redis_conn = redis.from_url( - current_app.config["REDIS_URL"], decode_responses=True - ) - return json.loads(redis_conn.hget("users", author)).get( - "full_name", author) - - def _get_diffs( diff_dir: str, user_id: str, redis_conn: redis.Redis, gn_proxy_url: str ): @@ -718,7 +711,13 @@ def show_case_attribute_columns(): if diff_data: for id_, author, diff in diff_data: diff = json.loads(diff) - author = _get_author(author) + author = get_user_info_by_key( + key="user_id", + value=author, + conn=redis.from_url( + current_app.config["REDIS_URL"], decode_responses=True + ) + ).get("full_name") if (m_ := diff.get("Modification")): m_["author"] = author m_["id"] = id_ -- cgit 1.4.1