def rename_startlist_by_id(startlist_id, startlist_new_name): try: startlist_db_object = StartlistNameModel.get_by_id(startlist_id) startlist_db_object.name = startlist_new_name startlist_db_object.save_to_db() return True except: return False
def results_specific_startlist(): startlist_id = request.form['startlist_select'] startlist_instance = StartlistNameModel.get_by_id(startlist_id) output_list = startlist_processing.result_list_generate(startlist_id) return render_template('startlist/results_specific_startlist.html', startlist_name=startlist_instance.name, data=output_list)
def startlist_one(): startlist_id = request.form['startlist_select'] startlist_instance = StartlistNameModel.get_by_id(startlist_id) output_list = startlist_processing.startlist_generate(startlist_id) output_length = startlist_processing.startlist_generate_length( startlist_id) return render_template('startlist/startlist_one.html', startlist_name=startlist_instance.name, data=output_list, length=output_length)
def delete_startlist_by_id(startlist_id): try: startlist_records = StartlistModel.get_by_startlist_id(startlist_id) for r in startlist_records: r.delete_from_db() startlist_db_object = StartlistNameModel.get_by_id(startlist_id) startlist_db_object.delete_from_db() # find all instances of the startlistmodel in startlist table # delete them one by one # delete the instance in the startlist model return True except: return False
def startlist_one_edit(): startlist_id = request.form['startlist_select'] # for startlist_one_edit_save() session['startlist_id'] = startlist_id startlist_instance = StartlistNameModel.get_by_id(startlist_id) output_list = startlist_processing.startlist_generate(startlist_id) output_length = startlist_processing.startlist_generate_length( startlist_id) rounds, line_count = startlist_processing.startlist_get_rounds_lines( startlist_id) return render_template('startlist/startlist_one_edit.html', startlist_name=startlist_instance.name, data=output_list, length=output_length, rounds=rounds, line_count=line_count)
def startlist_get_rounds_lines(startlist_id): startlist_instance = StartlistNameModel.get_by_id(startlist_id).json() return startlist_instance['startlist_rounds'], startlist_instance[ 'startline_count']
def wizard(): if request.method == 'POST': try: session['startlist_selected'] = request.form['startlist_select'] except: print("error - method wizard") try: startlist_selected = session['startlist_selected'] except KeyError: return redirect(url_for('.wizard_start')) startlist_instance = StartlistNameModel.get_by_id(startlist_selected) # it does nothing if session['counter'] already exists init_session_counter() if session['counter'] > startlist_instance.startlist_rounds: # indicates that there are times stored in this startlist startlist_instance.measured_flag = True startlist_instance.save_to_db() return redirect(url_for('.wizard_start')) found_records = [ record for record in StartlistModel.get_records_by_startlist_id_and_round_number( startlist_selected, session['counter']) ] startlist_round = [] for stm, ptm in found_records: record = (ptm.last_name, ptm.first_name, stm.start_position, stm.start_round, stm.id) startlist_round.append(record) # to easily receive startlist_id in the next_round() session['startlist_round'] = startlist_round startlist_lines = len(startlist_round) # not used at the moment # random_times = time_random(startlist_lines) # loading of the times from old database # db_times = [str(item.time_measured)[2:-4] for item in TimeDbModel.list_all()][-startlist_lines:] # session['random_times'] = db_times # loading of the times from the external database db_times_ext = [ str(item.time_measured)[2:-4] for item in TimyDbModel.list_all() ][-startlist_lines:] session['random_times'] = db_times_ext progress_now = session[ 'counter'] * 100 / startlist_instance.startlist_rounds progress_now_int = int(round(progress_now)) # Note: Verification if the site has been reloaded due to wrong assignment of startlines by user. # redirected from next_round() function. try: if session['wrong_entry'] == 1: session['wrong_entry'] = 0 return render_template( 'startlist/wizard_wrong_lines_assigned.html', name=startlist_instance.name, startlist=startlist_round, progress_now=progress_now_int, startlist_lines=startlist_lines, random_times=db_times_ext, rounds_count=startlist_instance.startlist_rounds) if session['wrong_entry'] == 2: session['wrong_entry'] = 0 return render_template( 'startlist/wizard_wrong_time_entered.html', name=startlist_instance.name, startlist=startlist_round, progress_now=progress_now_int, startlist_lines=startlist_lines, random_times=db_times_ext, rounds_count=startlist_instance.startlist_rounds) except KeyError: pass return render_template('startlist/wizard.html', name=startlist_instance.name, startlist=startlist_round, progress_now=progress_now_int, startlist_lines=startlist_lines, random_times=db_times_ext, rounds_count=startlist_instance.startlist_rounds)