Browse Source

para admin, ahora mismo solo se puede insertar no se puede update ni remover

Tatiana Castro 5 years ago
parent
commit
02b4cab6bc
2 changed files with 47 additions and 0 deletions
  1. 32
    0
      app/admin.py
  2. 15
    0
      app/templates/admin.html

+ 32
- 0
app/admin.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', __name__)
9
+
10
+@bp.route('/admin', 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, timeArrival, station)'
26
+            ' VALUES (?, ?, ?, ?, ?)',
27
+            (eName, office, turn, 0)
28
+        )
29
+        db.commit()
30
+        return redirect(url_for('admin'))
31
+
32
+    return render_template('admin.html')

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

@@ -0,0 +1,15 @@
1
+{% extends 'base.html' %}
2
+
3
+{% block header %}
4
+    <h1>{% block title %}UPR Queue{% 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="Get ticket">
14
+    </form>
15
+{% endblock %}