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)
def sorted(): project_name = get_current_project() proxy_id = DBProxy.get_proxy_id(project_name) project_proxy = DBProxy.get_proxy(proxy_id, database_model=False) return render_template( 'sorted.html', project_proxy=project_proxy, project_model=DBProxy.get_project(project_name=project_name))
def update_project_info(name, description, selection_prompt, preferred_prompt, unpreferred_prompt, consent_form, landing_page): project = DBProxy.get_project(project_name=name) if project is None: return False DBProxy.delete_all_consents_from_project(project_name=name) return DBProxy.update_project(name, description, selection_prompt, preferred_prompt, unpreferred_prompt, consent_form, landing_page)
def edit_project(): project_name = request.form.get('project_name_edit', None) if project_name is None: flash('project not found', 'warning') return redirect(url_for('dashboard')) project = DBProxy.get_project(project_name=project_name) if project is None: flash('project not found', 'warning') return redirect(url_for('dashboard')) return render_template('editproject.html', project=project)
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)
def instructions(): project_name = request.cookies.get('current_project') project = DBProxy.get_project(project_name=project_name) return render_template('instructions.html', landing_page=project.landing_page)
def consent_form(admin=False): project_name = request.cookies.get('current_project') project = DBProxy.get_project(project_name=project_name) return render_template('consentform.html', consent_form_text=project.consent_form, admin=admin)