from flask import ( Blueprint, flash, g, redirect, render_template, request, url_for ) from werkzeug.exceptions import abort from app.db import get_db from app.forms import StationForm bp = Blueprint('admin_insert', __name__) @bp.route('/admin_insert', methods=('GET', 'POST')) def admin_insert(): form = StationForm() if form.validate_on_submit(): db = get_db() db.execute( 'INSERT INTO station (nombre_empleado, oficina, last_turn)' ' VALUES (?, ?, ?)', (form.eName.data, form.office.data, 0) ) db.commit() flash('Added station for {} ({})'.format(form.eName.data, form.office.data)) return redirect(url_for('admin_insert')) return render_template('admin_insert.html', form=form)