diff options
Diffstat (limited to 'app/auth/routes.py')
| -rw-r--r-- | app/auth/routes.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/app/auth/routes.py b/app/auth/routes.py index fa792c2..0556233 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -30,8 +30,7 @@ from app.auth.email import ( send_password_reset_email, send_email_confirmation_email, ) -from app.models import User, Task -from app.utils.tasks import generate_user_task +from app.models import User, Task, Annotation LEGAL = markdown.markdown( @@ -92,6 +91,21 @@ def login(): current_user.last_active = datetime.datetime.utcnow() db.session.commit() + # remove any assigned unfinished datasets, as these may no longer be + # needed + user_tasks = Task.query.filter_by( + annotator_id=current_user.id, done=False + ).all() + for task in user_tasks: + anns = Annotation.query.filter_by(task_id=task.id).all() + if len(anns) > 0: + flash( + "Internal error, unfinished tasks has annotations!", + "error", + ) + db.session.delete(task) + db.session.commit() + # redirect if not confirmed yet if not user.is_confirmed: return redirect(url_for("auth.not_confirmed")) @@ -105,19 +119,6 @@ def login(): if not user.is_introduced: return redirect(url_for("main.index")) - # assign task if no remaining and not at maximum. - remaining = Task.query.filter_by( - annotator_id=user.id, done=False - ).all() - if remaining: - return redirect(next_page) - - task = generate_user_task(user) - if task is None: - return redirect(next_page) - - db.session.add(task) - db.session.commit() return redirect(next_page) return render_template("auth/login.html", title="Sign In", form=form) |
