Beispiel #1
0
def tower():
    email = get_email_from_request()
    project_name = get_current_project()
    if not DBProxy.user_has_signed_consent(email, project_name):
        return consent_form(admin=True)

    proxy_id = DBProxy.get_proxy_id(project_name=project_name)
    project_proxy = DBProxy.get_proxy(proxy_id, database_model=False)

    project_model = DBProxy.get_project(project_name=project_name)

    def time_left(expiration_time):
        time_seconds = expiration_time - time.time()
        seconds = int(time_seconds % 60)
        minutes = floor(time_seconds / 60)
        return f'{minutes} minute{("" if minutes == 1 else "s")}, ' \
               f'{seconds} second{("" if seconds == 1 else "s")}'

    roundList = DBProxy.get_round_list(project_name)
    checked_out = [
        x for x in roundList
        if (x.checked_out and x.expiration_time > time.time())
    ]
    active_judges = {x.user_checked_out_by for x in checked_out}

    return render_template('tower.html',
                           project_proxy=project_proxy,
                           time_left=time_left,
                           project_model=project_model,
                           roundList=roundList,
                           checked_out=checked_out,
                           active_judges=active_judges)
Beispiel #2
0
def sorter(admin=False, pair_id=None):
    email = get_email_from_request()
    project_name = get_current_project()
    if not DBProxy.user_has_signed_consent(email, project_name):
        return redirect(url_for('consent_form'))
    project = DBProxy.get_project(project_name=project_name)
    if not admin:
        pair, success_code = PairSelector.get_pair(project_name, email)
    else:
        pair, success_code = DBProxy.check_out_pair_by_id(pair_id, email)
    if success_code == 1:
        flash('no pair currently available', 'warning')
        return render_template('instructions.html')
    if success_code == 2:
        ProjectHandler.start_new_round(project_name)
        return redirect(url_for('sorter'))
    if success_code == 3:
        flash('project not found', 'warning')
        return redirect(url_for('dashboard'))
    if success_code == 4:
        flash('user not found', 'warning')
        return redirect(url_for('home'))
    if success_code == 5:
        flash('pair not found', 'warning')
        return redirect(url_for('tower'))
    file_one_contents = DBProxy.get_doc_contents(pair.doc1_id)
    file_two_contents = DBProxy.get_doc_contents(pair.doc2_id)
    return render_template('sorter.html',
                           pair_id=pair.id,
                           file_one_id=pair.doc1_id,
                           file_two_id=pair.doc2_id,
                           project=project,
                           time_started=floor(time.time()),
                           timeout=120 * 1000,
                           file_one=file_one_contents,
                           file_two=file_two_contents,
                           admin=admin)