diff options
author | BonfaceKilz | 2022-05-20 09:58:23 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-05-27 15:17:52 +0300 |
commit | 368dd574093e6d67b55e4224447395aabdd9e4dc (patch) | |
tree | 904198e0e8c97fcc78a6ca9ea531fd03bd8d2ff3 /wqflask | |
parent | 58a17d90c9895baa6884ec11b4ae17351736266c (diff) | |
download | genenetwork2-368dd574093e6d67b55e4224447395aabdd9e4dc.tar.gz |
Parse author id into a human readable name
* wqflask/wqflask/metadata_edits.py (_get_author):
New function.
(show_case_attribute_columns): Pass the author
name and id---case-attribute---field into the
template.
* wqflask/wqflask/templates/case_attributes.html:
Add an "author" column when displaying the
modified/deleted/inserted data. Also, add the
case-attribute's id as a data-id element.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/metadata_edits.py | 16 | ||||
-rw-r--r-- | wqflask/wqflask/templates/case_attributes.html | 16 |
2 files changed, 27 insertions, 5 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index e08e945e..dc2019c7 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -51,6 +51,14 @@ 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 ): @@ -710,8 +718,10 @@ def show_case_attribute_columns(): if diff_data: for author, diff in diff_data: diff = json.loads(diff) - diff["author"] = author + author = _get_author(author) if (m_ := diff.get("Modification")): + m_["author"] = author + m_["id"] = id_ if m_.get("description"): m_["description"]["Diff"] = "\n".join( difflib.ndiff( @@ -726,8 +736,12 @@ def show_case_attribute_columns(): )) modifications.append(m_) if (d_ := diff.get("Deletion")): + d_["author"] = author + d_["id"] = id_ deletions.append(d_) if (i_ := diff.get("Insert")): + i_["author"] = author + i_["id"] = id_ inserts.append(i_) # import pudb; pu.db diff --git a/wqflask/wqflask/templates/case_attributes.html b/wqflask/wqflask/templates/case_attributes.html index 0e11554a..4eaf5454 100644 --- a/wqflask/wqflask/templates/case_attributes.html +++ b/wqflask/wqflask/templates/case_attributes.html @@ -128,6 +128,7 @@ <h3>Modify Existing Case Attributes</h3> <table class="table table-responsive table-hover table-striped cell-border" id="table-modifications"> <thead> + <th scope="col">Author</th> <th scope="col">Diff</th> <th scope="col">Action</th> </thead> @@ -135,7 +136,8 @@ {% for data in modifications %} {% set reject_url = "" %} {% set approve_url = "" %} - <tr> + <tr data-id="{{ data.get('id') }}"> + <td>{{ data.get('author') }}</td> <td> {% if data.get("name")%} <b>Name:</b><br/> @@ -173,9 +175,11 @@ <col class="case-attribute"> <col> <col> + <col> </colgroup> <thead> <th scope="col">Case Attribute</th> + <th scope="col">Author</th> <th scope="col">Description</th> <th scope="col">Action</th> </thead> @@ -185,6 +189,7 @@ {% set approve_url = "" %} <tr data-id="{{data.get('id')}}"> <td> {{data.get("name")}} </td> + <td>{{ data.get('author') }}</td> <td> {{data.get("description")}} </td> <td> <button type="button" @@ -208,9 +213,11 @@ <col class="case-attribute"> <col> <col> + <col> </colgroup> <thead> <th scope="col">Case Attribute</th> + <th scope="col">Author</th> <th scope="col">Description</th> <th scope="col">Action</th> </thead> @@ -218,9 +225,10 @@ {% for data in inserts %} {% set reject_url = "" %} {% set approve_url = "" %} - <tr> - <td> {{data.get("name")}} </td> - <td> {{data.get("description")}} </td> + <tr data-id="{{ data.get('id') }}"> + <td>{{data.get("name")}}</td> + <td>{{ data.get('author')}}</td> + <td>{{data.get("description")}} </td> <td> <button type="button" class="btn btn-secondary btn-sm"> |