Browse Source

Adds to automatically go thru db for stations in form

Jose Reyes 6 years ago
parent
commit
4ff7f0de46
2 changed files with 11 additions and 3 deletions
  1. 6
    1
      app/index.py
  2. 5
    2
      app/templates/index.html

+ 6
- 1
app/index.py View File

@@ -41,4 +41,9 @@ def index():
41 41
         db.commit()
42 42
         return redirect(url_for('index'))
43 43
 
44
-    return render_template('index.html')
44
+    db = get_db()
45
+    stations = db.execute(
46
+        'SELECT s_id, nombre_empleado, oficina FROM station'
47
+        ' ORDER BY oficina ASC'
48
+    ).fetchall()
49
+    return render_template('index.html', stations=stations)

+ 5
- 2
app/templates/index.html View File

@@ -10,8 +10,11 @@
10 10
         <input name="cName" id="name" required></input><br>
11 11
 		<label for="cEmail">email</label>
12 12
         <input name="cEmail" id="email" required></input><br>
13
-        <input type="radio" name="station" id="station1" value="Fulano"> Fulano </input><br>
14
-        <input type="radio" name="station" id="station2" value="Mengana"> Mengana </input><br>
13
+
14
+        {% for station in stations %}
15
+            <input type="radio" name="station" id={{ "station{}".format(station['s_id']) }} value={{ station['nombre_empleado'] }}> {{ "{} ({})".format(station['nombre_empleado'],station['oficina']) }} </input><br>
16
+        {% endfor %}
17
+
15 18
         <input type="submit" value="Get ticket">
16 19
     </form>
17 20
 {% endblock %}