diff --git a/advlabdb/routes.py b/advlabdb/routes.py index 338220d..929588f 100644 --- a/advlabdb/routes.py +++ b/advlabdb/routes.py @@ -1,6 +1,7 @@ from advlabdb import app from flask import render_template, request, url_for from advlabdb.utils import * +from advlabdb.models import * @app.route("/") def index(): @@ -9,8 +10,54 @@ def index(): @app.route("/students") def students(): + parts = Semester.query.first().parts + tables = [] + tablesLabels = [] + for part in parts: + tablesLabels.append("Part" + part.label + ":") + + table = '' + table += th("Student number") + table += th("First name") + table += th("Last name") + table += th("Email") + table += th("Bachelor thesis") + table += th("BT WG") + table += th("Note") + table += th("Parts") + table += th("Final part mark") + table += th("GN") + table += th("Experiemt marks") + table += '\n\n' + + for partStudent in part.part_students: + student = partStudent.student + + table += '' + + table += td(student.student_number) + table += td(student.first_name) + table += td(student.last_name) + table += td(student.email) + table += td(student.bachelor_thesis) + table += td(student.bachelor_thesis_work_group) + table += td(student.note) + + table += td([ps.part for ps in student.part_students]) + + table += td(partStudent.final_part_mark) + table += td(partStudent.group.number) + + table += td(partStudent.experiment_marks) + + table += '\n' + + table += '' + tables.append(table) + page = "students" - return render_template(page + ".html", navbarItems=navbarItems(page)) + return render_template(page + ".html", navbarItems=navbarItems(page), + tables=tables, tablesLabels=tablesLabels) @app.route("/assistants") def assistants(): diff --git a/advlabdb/templates/layout.html b/advlabdb/templates/layout.html index 247d43d..9ff933d 100644 --- a/advlabdb/templates/layout.html +++ b/advlabdb/templates/layout.html @@ -7,6 +7,9 @@ + + + {% if title %} {{title}} @@ -30,7 +33,17 @@ {% block content %}{% endblock content %} + + + + + + + + + + diff --git a/advlabdb/templates/students.html b/advlabdb/templates/students.html index 39e893d..47d2464 100644 --- a/advlabdb/templates/students.html +++ b/advlabdb/templates/students.html @@ -1,3 +1,22 @@ {% extends "layout.html" %} {% block content %} + +{% for table in tables %} +{{tablesLabels[loop.index0]}} +
+ + {{table|safe}} +
+
+{% else %} +No parts in this semster yet! +{% endfor %} + {% endblock content %} diff --git a/advlabdb/utils.py b/advlabdb/utils.py index 25440c6..5cad379 100644 --- a/advlabdb/utils.py +++ b/advlabdb/utils.py @@ -6,5 +6,11 @@ def navbarItems(activePage): lowerPage = page.lower().replace(" ", "_") if lowerPage == activePage: active = " active" - items += '' + page + '\n' + items += '' + page + '' return items + +def td(cell): + return "" + str(cell) + "" + +def th(cell): + return '' + str(cell) + ''