Exemplo n.º 1
0
def edit_studyfield(studyfield_id):

    form = AddStudyfieldForm()
    studyfield = models.StudyField.query.get(studyfield_id)
    studies = models.Study.query.all()

    if form.validate_on_submit():
        name = form.name.data
        models.StudyField.update(studyfield, name)

        flash("The studyfield %r has been updated!" % str(name), "success")
        return redirect(url_for('admin'))

    return render_template("edit_studyfield.html", studyfield=studyfield, studies=studies, page_id="admin", title="Edit studyfield", form=form, u=g.user)
Exemplo n.º 2
0
def add_studyfield():
    form = AddStudyfieldForm()

    if form.validate_on_submit():
        name = form.name.data

        sf = models.StudyField(name=name)

        db.session.add(sf)
        db.session.commit()
        flash("The studyfield %r has been created!" % str(name), "success")
        return redirect(url_for('admin'))

    return render_template("add_studyfield.html", page_id="admin", title="Add study", form=form, u=g.user)