From 4362e738f604e71e9482f832fa744631925fd1f6 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 22 Dec 2021 15:34:18 +0300 Subject: metadata_edits: Return early if uploaded csv has not been edited --- wqflask/wqflask/metadata_edits.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index e0ceaf03..c8e73eec 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -259,6 +259,13 @@ def update_phenotype(dataset_id: str, name: str): r = run_cmd(cmd=("csvdiff " f"'{uploaded_file_name}' '{new_file_name}' " "--format json")) + + # Edge case where the csv file has not been edited! + if not any(json.loads(r.get("output")).values()): + flash(f"You have not modified the csv file you downloaded!", + "warning") + return redirect(f"/datasets/{dataset_id}/traits/{name}" + f"?resource-id={request.args.get('resource-id')}") diff_output = (f"{TMPDIR}/sample-data/diffs/" f"{_file_name}.json") with open(diff_output, "w") as f: -- cgit v1.2.3