예제 #1
0
def create(data):
    form = GigForm(data=data)
    if form.validate():
        pass
    else:
        return form.errors
    gig = Gig()
    gig.band = form.band.data
    gig.date = form.date.data
    gig.location = form.location.data
    gig.notes = form.notes.data
    return gig.put()
예제 #2
0
def gigs():
    form = GigForm()
    if form.validate_on_submit():
        if form.gig_id.data:
            # Update existing app
            gig = Gig.query.get(form.gig_id.data)
            if not gig:
                flash("Failed to delete gig.")
            else:
                gig.date = form.date.data
                gig.time = form.time.data
                gig.location = form.location.data
                gig.band = form.band.data
                gig.details = form.details.data
                db.session.commit()
                flash("Updated!")
                form.reset()
                return redirect(url_for("admin.gigs"))
        else:
            # Create new
            gig = Gig(
                date=form.date.data,
                time=form.time.data,
                location=form.location.data,
                band=form.band.data,
                details=form.details.data,
            )
            db.session.add(gig)
            db.session.commit()
            flash("Saved!")
            form.reset()
            return redirect(url_for("admin.gigs"))
    gigs = _fetch_gigs()
    return render_template("admin/gigs.html", gigs=gigs, form=form)