Create admin view table (no interaction yet)

This commit is contained in:
Sauer 2019-04-13 15:26:12 +02:00
parent 0bc9e3fb44
commit a9abb30810
3 changed files with 44 additions and 2 deletions

View File

@ -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():

View File

@ -100,3 +100,9 @@ header h1 {
.choice {
font-weight: 900;
}
/* table for admin view */
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}

View File

@ -1 +1,24 @@
{% extends "base.html" %}
{% block content %}
<h1>Übersicht</h1>
<table style="width: 100%">
<tr>
<th>id</th>
<th>computer</th>
<th>status</th>
<th>vegetable</th>
<th>spirit_animal</th>
<th>operating_system</th>
</tr>
{% for row in file_data %}
<tr>
<th>{{ row[0] }}</th>
<th>{{ row[1] }}</th>
<th>{{ row[2] }}</th>
<th>{{ row[3] }}</th>
<th>{{ row[4] }}</th>
<th>{{ row[5] }}</th>
</tr>
{% endfor %}
</table>
{% endblock %}