mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-10-05 19:32:15 +00:00
Added makeTable() and container
This commit is contained in:
parent
8b14dd30d4
commit
849318f249
5 changed files with 65 additions and 66 deletions
|
@ -56,7 +56,7 @@ class Experiment(db.Model):
|
|||
building = db.Column(db.String(100), nullable=False)
|
||||
responsibility = db.Column(db.String(200), nullable=True)
|
||||
duration_in_days = db.Column(db.Integer, nullable=False)
|
||||
deprecated = db.Column(db.Boolean, nullable=False, default=False) # To not be deleted!
|
||||
deprecated = db.Column(db.Boolean, nullable=False, default=False) # To not be deleted!
|
||||
oral_weighting = db.Column(db.Float, nullable=False)
|
||||
protocol_weighting = db.Column(db.Float, nullable=False)
|
||||
final_weighting = db.Column(db.Float, nullable=False)
|
||||
|
@ -98,15 +98,15 @@ class Assistant(db.Model):
|
|||
|
||||
class Appointment(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
date = db.Column(db.DateTime, nullable=False) # To be specified with the python package "datetime"
|
||||
special = db.Column(db.Boolean, nullable=False) # In the break or not
|
||||
date = db.Column(db.DateTime, nullable=False) # To be specified with the python package "datetime"
|
||||
special = db.Column(db.Boolean, nullable=False) # In the break or not
|
||||
group_experiment_id = db.Column(db.Integer, db.ForeignKey("group_experiment.id"), nullable=False)
|
||||
assistant_id = db.Column(db.Integer, db.ForeignKey("assistant.id"), nullable=False)
|
||||
|
||||
|
||||
class Part(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
label = db.Column(db.String(100), nullable=False) # A/1, A/2, B/1, B/2
|
||||
label = db.Column(db.String(100), nullable=False) # A/1, A/2, B/1, B/2
|
||||
semester_id = db.Column(db.Integer, db.ForeignKey("semester.id"), nullable=False)
|
||||
part_experiments = db.relationship("PartExperiment", backref="part", lazy=True)
|
||||
part_students = db.relationship("PartStudent", backref="part", lazy=True)
|
||||
|
@ -114,7 +114,7 @@ class Part(db.Model):
|
|||
|
||||
class Semester(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
label = db.Column(db.String(100), nullable=False) # WS2122 for example
|
||||
label = db.Column(db.String(100), nullable=False) # WS2122 for example
|
||||
parts = db.relationship("Part", backref="semester", lazy=True)
|
||||
|
||||
|
||||
|
@ -126,7 +126,7 @@ class ExperimentMark(db.Model):
|
|||
part_student_id = db.Column(db.Integer, db.ForeignKey("part_student.id"), nullable=False)
|
||||
group_experiment_id = db.Column(db.Integer, db.ForeignKey("group_experiment.id"), nullable=False)
|
||||
assistant_id = db.Column(db.Integer, db.ForeignKey("assistant.id"),
|
||||
nullable=True) # The assistant who gives the mark
|
||||
nullable=True) # The assistant who gives the mark
|
||||
|
||||
|
||||
class User(db.Model):
|
||||
|
|
|
@ -10,51 +10,26 @@ def index():
|
|||
|
||||
@app.route("/students")
|
||||
def students():
|
||||
parts = Semester.query.first().parts
|
||||
parts = Semester.query.all()[-1].parts
|
||||
tables = []
|
||||
tablesLabels = []
|
||||
|
||||
headerAndDataList = [["Student number", "row.student.student_number"],
|
||||
["First name", "row.student.first_name"],
|
||||
["Last name", "row.student.last_name"],
|
||||
["Email", "row.student.email"],
|
||||
["Bachelor thesis", "row.student.bachelor_thesis"],
|
||||
["BT WG", "row.student.bachelor_thesis_work_group"],
|
||||
["Note", "row.student.note"],
|
||||
["Parts", "[ps.part for ps in row.student.part_students]"],
|
||||
["Final part mark", "row.final_part_mark"],
|
||||
["GN", "row.group.number"],
|
||||
["Experiemt marks", "row.experiment_marks"]]
|
||||
|
||||
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)
|
||||
|
||||
tablesLabels.append("Part " + part.label + ":")
|
||||
tables.append(makeTable(headerAndDataList=headerAndDataList,
|
||||
rows=part.part_students))
|
||||
page = "students"
|
||||
return render_template(page + ".html", navbarItems=navbarItems(page),
|
||||
tables=tables, tablesLabels=tablesLabels)
|
||||
|
|
|
@ -31,7 +31,11 @@
|
|||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{% block content %}{% endblock content %}
|
||||
<div class="container-fluid">
|
||||
<br>
|
||||
{% block content %}{% endblock content %}
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<!-- 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>
|
||||
|
|
|
@ -2,19 +2,21 @@
|
|||
{% 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>
|
||||
<h2>{{tablesLabels[loop.index0]}}</h2>
|
||||
<table
|
||||
data-classes="table table-bordered table-striped"
|
||||
data-toggle="table"
|
||||
data-thead-classes="table-dark"
|
||||
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>
|
||||
<br>
|
||||
<hr>
|
||||
<br>
|
||||
{% else %}
|
||||
No parts in this semster yet!
|
||||
{% endfor %}
|
||||
|
|
|
@ -9,8 +9,26 @@ def navbarItems(activePage):
|
|||
items += '<a class="nav-link' + active + '" href="' + lowerPage + '">' + page + '</a>'
|
||||
return items
|
||||
|
||||
def td(cell):
|
||||
return "<td>" + str(cell) + "</td>"
|
||||
def makeTable(headerAndDataList, rows):
|
||||
def td(cell):
|
||||
return "<td>" + str(cell) + "</td>"
|
||||
|
||||
def th(cell):
|
||||
return '<th data-sortable="true">' + str(cell) + '</th>'
|
||||
def th(cell):
|
||||
return '<th data-sortable="true">' + str(cell) + '</th>'
|
||||
|
||||
|
||||
table = '<thead><tr>'
|
||||
for i in headerAndDataList:
|
||||
table += th(i[0])
|
||||
table += '</tr></thead>\n<tbody>\n'
|
||||
|
||||
for row in rows:
|
||||
table += '<tr>'
|
||||
|
||||
for i in headerAndDataList:
|
||||
table += td(eval(i[1]))
|
||||
|
||||
table += '</tr>\n'
|
||||
|
||||
table += '</tbody>'
|
||||
return table
|
||||
|
|
Loading…
Reference in a new issue