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 %} +
| id | +computer | +status | +vegetable | +spirit_animal | +operating_system | +
|---|---|---|---|---|---|
| {{ row[0] }} | +{{ row[1] }} | +{{ row[2] }} | +{{ row[3] }} | +{{ row[4] }} | +{{ row[5] }} | +