def vote(): annotator = utils.get_current_annotator() if annotator is not None: if annotator.prev.id == int( request.form['prev_id']) and annotator.next.id == int( request.form['next_id']): if request.form['action'] == 'Skip': annotator.ignore.append(annotator.next) else: if request.form['action'] == 'Previous': utils.perform_vote(annotator, next_won=False) decision = Decision(annotator, winner=annotator.prev, loser=annotator.next) elif request.form['action'] == 'Current': utils.perform_vote(annotator, next_won=True) decision = Decision(annotator, winner=annotator.next, loser=annotator.prev) db.session.add(decision) annotator.next.viewed.append(annotator) annotator.prev = annotator.next annotator.ignore.append(annotator.prev) annotator.next = utils.choose_next(annotator) db.session.commit() return redirect(url_for('index'))
def begin(): annotator = utils.get_current_annotator() if annotator is not None: if annotator.next.id == int(request.form['item_id']): annotator.ignore.append(annotator.next) if request.form['action'] == 'Done': annotator.prev = annotator.next annotator.next = utils.choose_next(annotator) elif request.form['action'] == 'Skip': annotator.next = None # will be reset in index db.session.commit() return redirect(url_for('index'))
def index(): annotator = utils.get_current_annotator() if annotator is None: return render_template('logged_out.html') else: utils.maybe_init_annotator(annotator) if annotator.next is None: return render_template('wait.html') elif annotator.prev is None: return render_template('begin.html', item=annotator.next) else: return render_template('vote.html', prev=annotator.prev, next=annotator.next)