def settings(): ''' Configuration page (web GUI). ''' cnfg = ConfigurationModel.find() if cnfg is None: abort(404) form = SettingsForm() #sets the values in the form if request.method != 'POST': form.dsgvo.default = cnfg.dsgvo form.quiz.default = cnfg.quizmode form.f.default = cnfg.global_f form.p.default = cnfg.global_p form.q.default = cnfg.global_q form.process() if form.validate_on_submit(): dsgvo = form.dsgvo.data quiz = form.quiz.data f = form.f.data p = form.p.data q = form.q.data if not check_fpq(f, p, q): print("Only values between 0 and 1 allowed for f,p,q!") #debug flash("Only values between 0 and 1 allowed for f,p,q!") return render_template('settings.html', form=form, cnfg=cnfg, title='client settings') cnfg.dsgvo = dsgvo cnfg.quizmode = quiz cnfg.global_f = f cnfg.global_p = p cnfg.global_q = q try: cnfg.save_to_db() except: return render_template( '/error_pages/500.html', title='error while trying to save inquiries.') return render_template('settings.html', form=form, cnfg=cnfg, title='client settings')
def index(day): form = SettingsForm() new_capture, new_capture_date, capture_days = session['data'] res_x, res_y, rotation, effect = getsettings() #this is the only way to set default values for select form inputs form.res_x.default = res_x form.res_y.default = res_y form.rotation.default = rotation form.effect.default = effect form.process() capture_objects = getcaptures(day.replace('_', ' ')) return render_template( 'index.html', form=form, new_capture=new_capture, new_capture_date=new_capture_date, capture_days=capture_days, capture_objects=capture_objects, res_x=res_x, res_y=res_y, rotation=rotation, effect=effect, )