mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2025-03-23 20:13:57 +00:00
Added Bootstrap Table and listed students
This commit is contained in:
parent
d06edf7e9c
commit
8b14dd30d4
4 changed files with 87 additions and 2 deletions
advlabdb
|
@ -1,6 +1,7 @@
|
||||||
from advlabdb import app
|
from advlabdb import app
|
||||||
from flask import render_template, request, url_for
|
from flask import render_template, request, url_for
|
||||||
from advlabdb.utils import *
|
from advlabdb.utils import *
|
||||||
|
from advlabdb.models import *
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
|
@ -9,8 +10,54 @@ def index():
|
||||||
|
|
||||||
@app.route("/students")
|
@app.route("/students")
|
||||||
def students():
|
def students():
|
||||||
|
parts = Semester.query.first().parts
|
||||||
|
tables = []
|
||||||
|
tablesLabels = []
|
||||||
|
for part in parts:
|
||||||
|
tablesLabels.append("Part" + part.label + ":")
|
||||||
|
|
||||||
|
table = '<thead><tr>'
|
||||||
|
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 += '</tr></thead>\n<tbody>\n'
|
||||||
|
|
||||||
|
for partStudent in part.part_students:
|
||||||
|
student = partStudent.student
|
||||||
|
|
||||||
|
table += '<tr>'
|
||||||
|
|
||||||
|
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 += '</tr>\n'
|
||||||
|
|
||||||
|
table += '</tbody>'
|
||||||
|
tables.append(table)
|
||||||
|
|
||||||
page = "students"
|
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")
|
@app.route("/assistants")
|
||||||
def assistants():
|
def assistants():
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
|
|
||||||
<!-- Bootstrap CSS -->
|
<!-- Bootstrap CSS -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
|
||||||
|
<!-- Bootstrap Table CSS -->
|
||||||
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.3/css/all.css" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.18.2/dist/bootstrap-table.min.css">
|
||||||
|
|
||||||
{% if title %}
|
{% if title %}
|
||||||
<title>{{title}}</title>
|
<title>{{title}}</title>
|
||||||
|
@ -30,7 +33,17 @@
|
||||||
</nav>
|
</nav>
|
||||||
{% block content %}{% endblock content %}
|
{% block content %}{% endblock content %}
|
||||||
|
|
||||||
|
<!-- jQuery JS -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||||
<!-- Bootstrap Bundle with Popper -->
|
<!-- Bootstrap Bundle with Popper -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
|
||||||
|
<!-- Bootstrap Table JS -->
|
||||||
|
<script src="https://unpkg.com/bootstrap-table@1.18.2/dist/bootstrap-table.min.js"></script>
|
||||||
|
<!-- Bootstrap Table Export extension JS -->
|
||||||
|
<script src="https://unpkg.com/tableexport.jquery.plugin/tableExport.min.js"></script>
|
||||||
|
<script src="https://unpkg.com/tableexport.jquery.plugin/libs/jsPDF/jspdf.min.js"></script>
|
||||||
|
<script src="https://unpkg.com/tableexport.jquery.plugin/libs/jsPDF-AutoTable/jspdf.plugin.autotable.js"></script>
|
||||||
|
<script src="https://unpkg.com/bootstrap-table@1.18.2/dist/extensions/export/bootstrap-table-export.min.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% for table in tables %}
|
||||||
|
{{tablesLabels[loop.index0]}}
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table
|
||||||
|
class="table table-striped"
|
||||||
|
data-toggle="table"
|
||||||
|
data-search="true"
|
||||||
|
data-show-toggle="true"
|
||||||
|
data-show-columns="true"
|
||||||
|
data-show-export="true"
|
||||||
|
data-export-types="['json', 'xml', 'csv', 'txt', 'sql', 'pdf']">
|
||||||
|
{{table|safe}}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
No parts in this semster yet!
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
@ -6,5 +6,11 @@ def navbarItems(activePage):
|
||||||
lowerPage = page.lower().replace(" ", "_")
|
lowerPage = page.lower().replace(" ", "_")
|
||||||
if lowerPage == activePage:
|
if lowerPage == activePage:
|
||||||
active = " active"
|
active = " active"
|
||||||
items += '<a class="nav-link' + active + '" href="' + lowerPage + '">' + page + '</a>\n'
|
items += '<a class="nav-link' + active + '" href="' + lowerPage + '">' + page + '</a>'
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
def td(cell):
|
||||||
|
return "<td>" + str(cell) + "</td>"
|
||||||
|
|
||||||
|
def th(cell):
|
||||||
|
return '<th data-sortable="true">' + str(cell) + '</th>'
|
||||||
|
|
Loading…
Add table
Reference in a new issue