Переглянути джерело

Adds to automatically go thru db for stations in form

Jose Reyes 5 роки тому
джерело
коміт
4ff7f0de46
2 змінених файлів з 11 додано та 3 видалено
  1. 6
    1
      app/index.py
  2. 5
    2
      app/templates/index.html

+ 6
- 1
app/index.py Переглянути файл

@@ -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 Переглянути файл

@@ -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 %}