aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-09-13 15:27:46 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-09-13 15:27:46 +0100
commit249f846b883656878b9b98cf0642f103aab7fc04 (patch)
tree455137155e29d091edbaf91292db86e01fd19956
parentAssign new tasks on the fly (diff)
downloadAnnotateChange-249f846b883656878b9b98cf0642f103aab7fc04.tar.gz
AnnotateChange-249f846b883656878b9b98cf0642f103aab7fc04.zip
Minor comments
-rw-r--r--app/main/routes.py12
-rw-r--r--app/utils/tasks.py1
2 files changed, 12 insertions, 1 deletions
diff --git a/app/main/routes.py b/app/main/routes.py
index 8a0e83e..75959a0 100644
--- a/app/main/routes.py
+++ b/app/main/routes.py
@@ -72,6 +72,7 @@ def assign():
db.session.commit()
return redirect(url_for("main.annotate", task_id=task.id))
+
@bp.route("/annotate/<int:task_id>", methods=("GET", "POST"))
@login_required
def annotate(task_id):
@@ -123,22 +124,31 @@ def annotate(task_id):
return url_for("main.index")
task = Task.query.filter_by(id=task_id).first()
+
+ # check if task exists
if task is None:
flash("No task with id %r exists." % task_id, "error")
return redirect(url_for("main.index"))
+
+ # check if task is assigned to this user
if not task.annotator_id == current_user.id:
flash(
"No task with id %r has been assigned to you." % task_id, "error"
)
return redirect(url_for("main.index"))
+
+ # check if task is not already done
if task.done:
flash("It's not possible to edit annotations at the moment.")
return redirect(url_for("main.index"))
+
data = load_data_for_chart(task.dataset.name, task.dataset.md5sum)
if data is None:
flash(
- "An internal error occurred loading this dataset, the admin has been notified. Please try again later. We apologise for the inconvenience."
+ "An internal error occurred loading this dataset, the admin has been notified. Please try again later. We apologise for the inconvenience.",
+ "error",
)
+ return redirect(url_for("main.index"))
title = f"Dataset: {task.dataset.id}"
is_multi = len(data["chart_data"]["values"]) > 1
return render_template(
diff --git a/app/utils/tasks.py b/app/utils/tasks.py
index 1d7eec8..61155de 100644
--- a/app/utils/tasks.py
+++ b/app/utils/tasks.py
@@ -55,6 +55,7 @@ def generate_user_task(user):
continue
potential_datasets.append((n_needed, dataset))
+ # don't assign a dataset if there are no more datasets to annotate
if len(potential_datasets) == 0:
return None