No Description

admin.py 972B

1234567891011121314151617181920212223242526272829303132
  1. from flask import (
  2. Blueprint, flash, g, redirect, render_template, request, url_for
  3. )
  4. from werkzeug.exceptions import abort
  5. from app.db import get_db
  6. bp = Blueprint('admin', __name__)
  7. @bp.route('/admin', methods=('GET', 'POST'))
  8. def admin():
  9. if request.method == 'POST':
  10. eName = request.form['eName']
  11. office = request.form['oficina']
  12. last_turn = request.form['turno']
  13. db = get_db()
  14. station_query_res = db.execute(
  15. 'SELECT s_id FROM station WHERE nombre_empleado=?',
  16. (station_name,)
  17. ).fetchone()
  18. if station_query_res is not None:
  19. station_id = station_query_res[0]
  20. db.execute(
  21. 'INSERT INTO station (nombre_empleado, oficina, last_turn, timeArrival, station)'
  22. ' VALUES (?, ?, ?, ?, ?)',
  23. (eName, office, turn, 0)
  24. )
  25. db.commit()
  26. return redirect(url_for('admin'))
  27. return render_template('admin.html')