Tatiana Castro 6 years ago
parent
commit
b883087b3b
2 changed files with 47 additions and 0 deletions
  1. 32
    0
      app/admin_insert.py
  2. 15
    0
      app/templates/admin_insert.html

+ 32
- 0
app/admin_insert.py View File

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

+ 15
- 0
app/templates/admin_insert.html View File

@@ -0,0 +1,15 @@
1
+{% extends 'base.html' %}
2
+
3
+{% block header %}
4
+    <h1>{% block title %}UPR Queue: Insert Station{% endblock %}</h1>
5
+{% endblock %}
6
+
7
+{% block content %}
8
+    <form method="post">
9
+        <label for="eName">Name</label>
10
+        <input name="eName" id="name" required></input><br>
11
+        <label for="eName">Oficina</label>
12
+        <input name="oficina" id="oficina" required></input><br>
13
+        <input type="submit" value="Insert Station">
14
+    </form>
15
+{% endblock %}