def edit(result_id): result = Result.query.get_or_404(result_id) #result.permissions.edit.test(403) form = ResultForm(obj=result) if form.validate_on_submit(): form.populate_obj(result) result.save() flash(u"你的条目已更新", "successfully") return redirect(url_for("result.view", result_id=result_id)) return render_template("result/edit_result.html", result=result, form=form)
def add(): form = ResultForm() form.case.choices = [(c.id, c.name) for c in Case.query.all()] if form.validate_on_submit(): result = Result() form.populate_obj(result) result.case = Case.query.filter(Case.id==form.case.data).first_or_404() result.author = current_user result.save() flash("Add Test Result successfully") return redirect(url_for("result.view", result_id=result.id)) return render_template("result/add.html", form=form)
def add(): form = ResultForm() form.case.choices = [(c.id, c.name) for c in Case.query.all()] if form.validate_on_submit(): result = Result() form.populate_obj(result) result.case = Case.query.filter( Case.id == form.case.data).first_or_404() result.author = current_user result.save() flash("Add Test Result successfully") return redirect(url_for("result.view", result_id=result.id)) return render_template("result/add.html", form=form)
def results(): frame = session.pop('frame', 'All') if frame == 'All': begin_frame = int(0) end_frame = int(6) else: end_frame = int(frame) begin_frame = int(frame) - 1 ch = session.pop('ch', None) plot_data = [] if ch: results, setups = germix_fastai_webapp.logic( f'{app.static_folder}/{ch}', interval=1, begin_frame=begin_frame, end_frame=end_frame, show=False) frame_overview, _ = get_frame_overview(ch, setups=setups) for j in range(begin_frame, end_frame): img = BytesIO() fig, ax = plt.subplots() ax.plot(list(results[j].keys()), list(results[j].values())) ax.set_xlabel('Time') ax.set_ylabel('Quantity') ax.set_title(f'Germination graph for frame {j+1}') plt.savefig(img, format='png') img.seek(0) plot_data.append( urllib.parse.quote(base64.b64encode(img.read()).decode())) form = ResultForm() text = [f'Results for image Stack {ch}'] if form.validate_on_submit(): if form.export.data: pass if form.other.data: return redirect(url_for('select')) return render_template('results.html', title='Results', plot_url=plot_data, form=form, text=text, frame_overview=frame_overview)