aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 %}