aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2022-05-20 10:34:55 +0300
committerBonfaceKilz2022-05-27 15:17:52 +0300
commit4dc286cae2d453db3e99ef06eb27343a2f6e0c07 (patch)
treec8e8f5f525acddb7ba7ad4243fac23e7d9db2ed8 /wqflask
parentd995399aef90aca58857bb488bb5f50ff4f996fe (diff)
downloadgenenetwork2-4dc286cae2d453db3e99ef06eb27343a2f6e0c07.tar.gz
Implement "reject"---for case-attr---endpoint
* wqflask/wqflask/metadata_edits.py (show_case_attribute_columns): Fetch id---this is already passed in the template---when getting case attributes. (reject_case_attribute_data): New endpoint for rejecting data. * wqflask/wqflask/templates/case_attributes.html: Add JS logic for rejecting data.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/metadata_edits.py25
-rw-r--r--wqflask/wqflask/templates/case_attributes.html14
2 files changed, 37 insertions, 2 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py
index dc2019c7..dcadcc99 100644
--- a/wqflask/wqflask/metadata_edits.py
+++ b/wqflask/wqflask/metadata_edits.py
@@ -711,12 +711,12 @@ def show_case_attribute_columns():
with database_connection() as conn:
with conn.cursor() as cursor:
cursor.execute(
- "SELECT editor, json_diff_data FROM "
+ "SELECT id, editor, json_diff_data FROM "
"caseattributes_audit WHERE status = 'review'")
diff_data = cursor.fetchall()
modifications, deletions, inserts = [], [], []
if diff_data:
- for author, diff in diff_data:
+ for id_, author, diff in diff_data:
diff = json.loads(diff)
author = _get_author(author)
if (m_ := diff.get("Modification")):
@@ -782,3 +782,24 @@ def update_case_attributes():
conn.commit()
return redirect(url_for("metadata_edit.show_case_attribute_columns"))
+
+
+@metadata_edit.route("/case-attributes/reject", methods=["POST", ])
+def reject_case_attribute_data():
+ case_attr_id = request.form.to_dict().get("id")
+ with database_connection() as conn:
+ if case_attr_id:
+ try:
+ with conn.cursor() as cursor:
+ cursor.execute(
+ "UPDATE caseattributes_audit SET "
+ "status = 'rejected' WHERE id = %s",
+ case_attr_id
+ )
+ except Exception as _e:
+ import MySQLdb
+ conn.rollback()
+ raise MySQLdb.Error(_e) from _e
+ conn.commit()
+
+ return redirect(url_for("metadata_edit.show_case_attribute_columns"))
diff --git a/wqflask/wqflask/templates/case_attributes.html b/wqflask/wqflask/templates/case_attributes.html
index 1e2deb88..1e1bc98a 100644
--- a/wqflask/wqflask/templates/case_attributes.html
+++ b/wqflask/wqflask/templates/case_attributes.html
@@ -375,5 +375,19 @@
})}
});
});
+
+ $(".reject").click(function(){
+ let id = $(this).data("id")
+ if (Number.isInteger(id)) {
+ $.ajax({
+ type: "POST",
+ data: {"id": id},
+ url: '{{ url_for("metadata_edit.reject_case_attribute_data") }}',
+ success: function(data, status, xhr) {
+ location.reload();
+ }
+ })
+ }
+ });
</script>
{% endblock %}