From a9abb308100640a6b3fb2c8dc615fdcebcd408d0 Mon Sep 17 00:00:00 2001 From: asauer Date: Sat, 13 Apr 2019 15:26:12 +0200 Subject: [PATCH] Create admin view table (no interaction yet) --- gruppenbildungsspiel.py | 17 +++++++++++++++-- static/main.css | 6 ++++++ templates/admin.html | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/gruppenbildungsspiel.py b/gruppenbildungsspiel.py index 669d00b..4b2743f 100644 --- a/gruppenbildungsspiel.py +++ b/gruppenbildungsspiel.py @@ -77,9 +77,22 @@ def questions(): def result(user_id): return render_template('result.html', title='Sortierhut', hausname='Knuth', haustext='Mitglieder dieses Hauses mögen LaTeX-Anzüge und Eisbären.', id=user_id) -@app.route('/admin') +def convert_csv_to_list_of_lists(): + list_of_lists = list() + + if not os.path.exists(datafile): + open(datafile, 'a').close() + + with open(datafile, 'r', newline='') as f: + reader = csv.reader(f) + for line in reader: + list_of_lists.append(line) + return list_of_lists + +@app.route('/admint_rocks_20190417') def admin(): - return render_template('admin.html', title='Sortierhut', text='Hallo, Admin Fooboar') + file_data = convert_csv_to_list_of_lists() + return render_template('admin.html', title='Sortierhut', text='Hallo, Admin Fooboar', file_data=file_data) @app.route('/answers', methods=['GET', 'POST']) def answers(): diff --git a/static/main.css b/static/main.css index f307db7..5e3fecb 100644 --- a/static/main.css +++ b/static/main.css @@ -100,3 +100,9 @@ header h1 { .choice { font-weight: 900; } + +/* table for admin view */ +table, th, td { + border: 1px solid black; + border-collapse: collapse; +} diff --git a/templates/admin.html b/templates/admin.html index 94d9808..71d8042 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -1 +1,24 @@ {% extends "base.html" %} +{% block content %} +

Übersicht

+ + + + + + + + + + {% for row in file_data %} + + + + + + + + + {% endfor %} +
idcomputerstatusvegetablespirit_animaloperating_system
{{ row[0] }}{{ row[1] }}{{ row[2] }}{{ row[3] }}{{ row[4] }}{{ row[5] }}
+{% endblock %}