From 305a2fc37bc233c9842bb12346c7e476c1d81be7 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 30 Jul 2021 16:38:43 +0300 Subject: wqflask: views: Flash messages during edits --- wqflask/wqflask/templates/edit_phenotype.html | 9 +++++++++ wqflask/wqflask/views.py | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/templates/edit_phenotype.html b/wqflask/wqflask/templates/edit_phenotype.html index 83daba58..0d7071f7 100644 --- a/wqflask/wqflask/templates/edit_phenotype.html +++ b/wqflask/wqflask/templates/edit_phenotype.html @@ -2,6 +2,15 @@ {% block title %}Trait Submission{% endblock %} {% block content %} +{% with messages = get_flashed_messages(with_categories=true) %} +{% if messages %} +{% for category, message in messages %} +
+

{{ message }}

+
+{% endfor %} +{% endif %} +{% endwith %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 0f1df123..18d3e99f 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -546,7 +546,7 @@ def update_phenotype(): data_ = request.form.to_dict() author = g.user_session.record.get(b'user_name') if 'file' not in request.files: - flash("No sample data has been uploaded") + flash("No sample-data has been uploaded", "warning") else: file_ = request.files['file'] trait_name = str(data_.get('dataset-name')) @@ -598,6 +598,7 @@ def update_phenotype(): dict_.update({"timestamp": datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S")}) f.write(json.dumps(dict_)) + flash("Sample-data has been successfully uploaded", "success") # Run updates: phenotype_ = { "pre_pub_description": data_.get("pre-pub-desc"), @@ -649,6 +650,7 @@ def update_phenotype(): data=MetadataAudit(dataset_id=data_.get("dataset-name"), editor=author.decode("utf-8"), json_data=json.dumps(diff_data))) + flash(f"Diff-data: \n{diff_data}\nhas been uploaded", "success") return redirect(f"/trait/{data_.get('dataset-name')}" f"/edit/phenotype-id/{data_.get('phenotype-id')}") -- cgit v1.2.3