aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorMunyoki Kilyungi2022-08-08 12:34:38 +0300
committerBonfaceKilz2022-08-09 08:28:08 +0300
commit9ad492d03acbb30b5c6d67d98c55bf7bc878e00e (patch)
tree3408502dd8cbcc0e9f9e5d0ea9cb40228c19ae8c /wqflask
parent9216e88a8e7af186e6236ea63c74e951f769f2cd (diff)
downloadgenenetwork2-9ad492d03acbb30b5c6d67d98c55bf7bc878e00e.tar.gz
Remove "diff" logic from edit_probeset
* wqflask/wqflask/metadata_edits.py (edit_probeset): Delete logic for fetching diff. Move that... (show_history): ... here * wqflask/wqflask/templates/edit_probeset.html: Update template to show diffs in a history.html. Reposition and rename the h1 tag of this page.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/metadata_edits.py69
-rw-r--r--wqflask/wqflask/templates/edit_probeset.html9
2 files changed, 29 insertions, 49 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py
index 4b960072..0840d4dd 100644
--- a/wqflask/wqflask/metadata_edits.py
+++ b/wqflask/wqflask/metadata_edits.py
@@ -127,40 +127,7 @@ def edit_probeset(conn, name):
columns=list(probeset_mapping.values()),
where=Probeset(name=name),
)
- json_data = fetchall(
- conn, "metadata_audit", where=MetadataAudit(dataset_id=probeset_.id_)
- )
- Edit = namedtuple("Edit", ["field", "old", "new", "diff"])
- Diff = namedtuple("Diff", ["author", "diff", "timestamp"])
- diff_data = []
- for data in json_data:
- json_ = json.loads(data.json_data)
- timestamp = json_.get("timestamp")
- author = json_.get("author")
- for key, value in json_.items():
- if isinstance(value, dict):
- for field, data_ in value.items():
- diff_data.append(
- Diff(
- author=author,
- diff=Edit(
- field,
- data_.get("old"),
- data_.get("new"),
- "\n".join(
- difflib.ndiff(
- [data_.get("old")], [data_.get("new")]
- )
- ),
- ),
- timestamp=timestamp,
- )
- )
- diff_data_ = None
- if len(diff_data) > 0:
- diff_data_ = groupby(diff_data, lambda x: x.timestamp)
return {
- "diff": diff_data_,
"probeset": probeset_,
}
@@ -554,21 +521,31 @@ def show_diff(name):
@metadata_edit.route("/<dataset_id>/traits/<name>/history")
-def show_history(dataset_id: str, name: str):
+@metadata_edit.route("/probeset/<name>")
+def show_history(dataset_id: str = "", name: str = ""):
diff_data_ = None
with database_connection() as conn:
- publish_xref = fetchone(
- conn=conn,
- table="PublishXRef",
- where=PublishXRef(id_=name, inbred_set_id=dataset_id),
- )
-
- json_data = fetchall(
- conn,
- "metadata_audit",
- where=MetadataAudit(dataset_id=publish_xref.id_),
- )
-
+ json_data = None
+ if dataset_id: # This is a published phenotype
+ json_data = fetchall(
+ conn,
+ "metadata_audit",
+ where=MetadataAudit(dataset_id=fetchone(
+ conn=conn,
+ table="PublishXRef",
+ where=PublishXRef(id_=name, inbred_set_id=dataset_id),
+ ).id_),
+ )
+ else: # This is a probeset
+ json_data = fetchall(
+ conn, "metadata_audit",
+ where=MetadataAudit(dataset_id=fetchone(
+ conn=conn,
+ table="ProbeSet",
+ columns=list(probeset_mapping.values()),
+ where=Probeset(name=name),
+ ).id_)
+ )
Edit = namedtuple("Edit", ["field", "old", "new", "diff"])
Diff = namedtuple("Diff", ["author", "diff", "timestamp"])
diff_data = []
diff --git a/wqflask/wqflask/templates/edit_probeset.html b/wqflask/wqflask/templates/edit_probeset.html
index ab91b701..d9aee9d8 100644
--- a/wqflask/wqflask/templates/edit_probeset.html
+++ b/wqflask/wqflask/templates/edit_probeset.html
@@ -2,8 +2,12 @@
{% block title %}Trait Submission{% endblock %}
{% block content %}
<!-- Start of body -->
-Edit Trait for Probeset
-Submit Trait | Reset
+<div class="container">
+ <div class="page-header text-left">
+ <h1>Probeset Editing Form:</h1>
+ <small><a href="{{url_for('metadata_edit.show_history', name=name)}}" target="_blank">[View History]</a></small>
+ </div>
+</div>
{% if diff %}
@@ -54,7 +58,6 @@ Submit Trait | Reset
{% endif %}
<form id="edit-form" class="form-horizontal" method="post" action="/datasets/traits/{{ name }}?resource-id={{ resource_id }}">
- <h2 class="text-center">Probeset Information:</h2>
<div class="form-group">
<label for="symbol" class="col-sm-2 control-label">Symbol:</label>
<div class="col-sm-4">