|
@@ -4,22 +4,24 @@ from flask import (
|
4
|
4
|
from werkzeug.exceptions import abort
|
5
|
5
|
|
6
|
6
|
from app.db import get_db
|
|
7
|
+from app.forms import StationForm
|
7
|
8
|
|
8
|
9
|
bp = Blueprint('admin_insert', __name__)
|
9
|
10
|
|
10
|
11
|
@bp.route('/admin_insert', methods=('GET', 'POST'))
|
11
|
12
|
def admin():
|
12
|
|
- if request.method == 'POST':
|
13
|
|
- eName = request.form['eName']
|
14
|
|
- office = request.form['oficina']
|
15
|
|
-
|
|
13
|
+ form = StationForm()
|
|
14
|
+ if form.validate_on_submit():
|
16
|
15
|
db = get_db()
|
17
|
16
|
db.execute(
|
18
|
17
|
'INSERT INTO station (nombre_empleado, oficina, last_turn)'
|
19
|
18
|
' VALUES (?, ?, ?)',
|
20
|
|
- (eName, office, 0)
|
|
19
|
+ (form.eName.data, form.office.data, 0)
|
21
|
20
|
)
|
22
|
21
|
db.commit()
|
|
22
|
+
|
|
23
|
+ flash('Added station for {} ({})'.format(form.eName.data, form.office.data))
|
|
24
|
+
|
23
|
25
|
return redirect(url_for('admin_insert'))
|
24
|
26
|
|
25
|
|
- return render_template('admin_insert.html')
|
|
27
|
+ return render_template('admin_insert.html', form=form)
|