def add(): form = EventForm(request.form) if form.validate_on_submit(): event = Event(name=form.name.data, play_length=form.play_length.data) event_dao.create_event(event) flash('Event added.', 'success') return redirect(url_for("main.home")) return render_template('event/add.html', form=form)
def edit(event_id): event = event_dao.get_event_by_id(event_id) form = EventForm(request.form, event) if form.validate_on_submit() and request.method == 'POST': form.populate_obj(event) event_dao.update_event(event) flash("Event Edited", 'success') return redirect(url_for("main.home")) return render_template('event/edit.html', form=form, event_id=event_id)