mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Added part_id to Group, added experiments and groups tables, updated all CDNs to jsDelivery.
This commit is contained in:
parent
e95cb842fe
commit
7a5a852cd7
8 changed files with 79 additions and 19 deletions
File diff suppressed because one or more lines are too long
|
@ -35,6 +35,7 @@ class PartStudent(db.Model):
|
||||||
class Group(db.Model):
|
class Group(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
number = db.Column(db.Integer, nullable=False)
|
number = db.Column(db.Integer, nullable=False)
|
||||||
|
part_id = db.Column(db.Integer, db.ForeignKey("part.id"), nullable=False)
|
||||||
part_students = db.relationship("PartStudent", backref="group", lazy=True)
|
part_students = db.relationship("PartStudent", backref="group", lazy=True)
|
||||||
group_experiments = db.relationship("GroupExperiment", backref="group", lazy=True)
|
group_experiments = db.relationship("GroupExperiment", backref="group", lazy=True)
|
||||||
|
|
||||||
|
@ -110,6 +111,7 @@ class Part(db.Model):
|
||||||
semester_id = db.Column(db.Integer, db.ForeignKey("semester.id"), nullable=False)
|
semester_id = db.Column(db.Integer, db.ForeignKey("semester.id"), nullable=False)
|
||||||
part_experiments = db.relationship("PartExperiment", backref="part", lazy=True)
|
part_experiments = db.relationship("PartExperiment", backref="part", lazy=True)
|
||||||
part_students = db.relationship("PartStudent", backref="part", lazy=True)
|
part_students = db.relationship("PartStudent", backref="part", lazy=True)
|
||||||
|
groups = db.relationship("Group", backref="part", lazy=True)
|
||||||
|
|
||||||
|
|
||||||
class Semester(db.Model):
|
class Semester(db.Model):
|
||||||
|
|
|
@ -19,13 +19,13 @@ def students():
|
||||||
["First name", "row.student.first_name"],
|
["First name", "row.student.first_name"],
|
||||||
["Last name", "row.student.last_name"],
|
["Last name", "row.student.last_name"],
|
||||||
["Email", "row.student.email"],
|
["Email", "row.student.email"],
|
||||||
|
["GN", "row.group.number"],
|
||||||
["Bachelor thesis", "row.student.bachelor_thesis"],
|
["Bachelor thesis", "row.student.bachelor_thesis"],
|
||||||
["BT WG", "row.student.bachelor_thesis_work_group"],
|
["BT WG", "row.student.bachelor_thesis_work_group"],
|
||||||
["Note", "row.student.note"],
|
["Note", "row.student.note"],
|
||||||
["Parts", "[ps.part for ps in row.student.part_students]"],
|
|
||||||
["Final part mark", "row.final_part_mark"],
|
["Final part mark", "row.final_part_mark"],
|
||||||
["GN", "row.group.number"],
|
["Experiemt marks", "row.experiment_marks"],
|
||||||
["Experiemt marks", "row.experiment_marks"]]
|
["Parts", "[ps.part for ps in row.student.part_students]"]]
|
||||||
|
|
||||||
for part in parts:
|
for part in parts:
|
||||||
tablesLabels.append("Part " + part.label + ":")
|
tablesLabels.append("Part " + part.label + ":")
|
||||||
|
@ -57,8 +57,24 @@ def assistants():
|
||||||
|
|
||||||
@app.route("/experiments")
|
@app.route("/experiments")
|
||||||
def experiments():
|
def experiments():
|
||||||
|
semester = Semester.query.all()[-1]
|
||||||
|
parts = semester.parts
|
||||||
|
tables = []
|
||||||
|
tablesLabels = []
|
||||||
|
|
||||||
|
headerAndDataList = [["Name", "row.experiment.name"],
|
||||||
|
["Number", "row.number"],
|
||||||
|
["Assistants", "row.assistants"],
|
||||||
|
["Groups with this ex.", "[gEx.group.number for gEx in row.group_experiments]"]]
|
||||||
|
|
||||||
|
for part in parts:
|
||||||
|
tablesLabels.append("Part " + part.label + ":")
|
||||||
|
tables.append(makeTable(headerAndDataList=headerAndDataList,
|
||||||
|
rows=part.part_experiments))
|
||||||
|
|
||||||
page = "experiments"
|
page = "experiments"
|
||||||
return render_template(page + ".html", navbarItems=navbarItems(page))
|
return render_template(page + ".html", navbarItems=navbarItems(page),
|
||||||
|
tables=tables, tablesLabels=tablesLabels)
|
||||||
|
|
||||||
@app.route("/appointments")
|
@app.route("/appointments")
|
||||||
def appointments():
|
def appointments():
|
||||||
|
@ -67,8 +83,25 @@ def appointments():
|
||||||
|
|
||||||
@app.route("/groups")
|
@app.route("/groups")
|
||||||
def groups():
|
def groups():
|
||||||
|
semester = Semester.query.all()[-1]
|
||||||
|
parts = semester.parts
|
||||||
|
tables = []
|
||||||
|
tablesLabels = []
|
||||||
|
|
||||||
|
headerAndDataList = [["Number", "row.number"],
|
||||||
|
["Students",
|
||||||
|
"[ps.student.first_name + ' ' + ps.student.last_name for ps in row.part_students]"],
|
||||||
|
["Experiments (appointments)",
|
||||||
|
"[str(gx.part_experiment.number) + ' (' + str([appointmentDate(a.date) for a in gx.appointments]) + ')' for gx in row.group_experiments]"]]
|
||||||
|
|
||||||
|
for part in parts:
|
||||||
|
tablesLabels.append("Part " + part.label + ":")
|
||||||
|
tables.append(makeTable(headerAndDataList=headerAndDataList,
|
||||||
|
rows=part.groups))
|
||||||
|
|
||||||
page = "groups"
|
page = "groups"
|
||||||
return render_template(page + ".html", navbarItems=navbarItems(page))
|
return render_template(page + ".html", navbarItems=navbarItems(page),
|
||||||
|
tables=tables, tablesLabels=tablesLabels)
|
||||||
|
|
||||||
@app.route("/users")
|
@app.route("/users")
|
||||||
def users():
|
def users():
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% for table in tables %}
|
||||||
|
<h2>{{tablesLabels[loop.index0]}}</h2>
|
||||||
|
{{table|safe}}
|
||||||
|
{% else %}
|
||||||
|
No parts in this semster yet!
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% for table in tables %}
|
||||||
|
<h2>{{tablesLabels[loop.index0]}}</h2>
|
||||||
|
{{table|safe}}
|
||||||
|
{% else %}
|
||||||
|
No parts in this semster yet!
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<!-- 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 rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" integrity="sha256-nq7J0kse50upWdNiXRDsuGd/AkfaHz0hX8HgCUsCASY=" crossorigin="anonymous">
|
||||||
|
<!-- Fontawesome CSS -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
|
||||||
<!-- Bootstrap Table CSS -->
|
<!-- 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://cdn.jsdelivr.net/npm/bootstrap-table@1.18.2/dist/bootstrap-table.min.css" integrity="sha256-mypXFtMz9LOewBHR7iL9Ls3/eerooDeTAtLpo6gmTwU=" 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>
|
||||||
|
@ -40,14 +41,14 @@
|
||||||
<!-- jQuery JS -->
|
<!-- 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>
|
<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="sha256-tfbRzZ36wuPoeUKXyuewrLOzcfgdO2ovc4ozuYRWMs4=" crossorigin="anonymous"></script>
|
||||||
<!-- Bootstrap Table JS -->
|
<!-- Bootstrap Table JS -->
|
||||||
<script src="https://unpkg.com/bootstrap-table@1.18.2/dist/bootstrap-table.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.18.2/dist/bootstrap-table.min.js" integrity="sha256-8mXaKD8IdqCXwwzNpp/WHddQZi77Bin0cma5y1G+B9E=" crossorigin="anonymous"></script>
|
||||||
<!-- Bootstrap Table Export extension JS -->
|
<!-- Bootstrap Table Export extension JS -->
|
||||||
<script src="https://unpkg.com/tableexport.jquery.plugin/tableExport.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/tableexport.jquery.plugin@1.10.21/libs/FileSaver/FileSaver.min.js" integrity="sha256-S1CD3kZ9K/shgqLK8lnh6K5A/GQANjwwG+gLA1OL+Jg=" crossorigin="anonymous"></script>
|
||||||
<script src="https://unpkg.com/tableexport.jquery.plugin/libs/jsPDF/jspdf.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/tableexport.jquery.plugin@1.10.21/libs/jsPDF/jspdf.min.js" integrity="sha256-B74p+AfarPBbH2e1zQiOJFDizKgXS2sPNkUsST4+cKA=" crossorigin="anonymous"></script>
|
||||||
<script src="https://unpkg.com/tableexport.jquery.plugin/libs/jsPDF-AutoTable/jspdf.plugin.autotable.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/tableexport.jquery.plugin@1.10.21/libs/jsPDF-AutoTable/jspdf.plugin.autotable.js" integrity="sha256-V3ovkrEpDyy74G52YBOG4TSBoC2sHkbbitBEp9/kZcY=" crossorigin="anonymous"></script>
|
||||||
<script src="https://unpkg.com/bootstrap-table@1.18.2/dist/extensions/export/bootstrap-table-export.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/tableexport.jquery.plugin@1.10.21/tableExport.min.js" integrity="sha256-/VfFIAF4GLBN7iah7RFGi+zISoczKczfQTP4Dh4N0uw=" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.18.2/dist/extensions/export/bootstrap-table-export.min.js" integrity="sha256-C4hVBAtUi42+NXYGkjgx4WD7lGG205ZVtcHo6UMIge8=" crossorigin="anonymous"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -11,7 +11,12 @@ def navbarItems(activePage):
|
||||||
|
|
||||||
def makeTable(headerAndDataList, rows):
|
def makeTable(headerAndDataList, rows):
|
||||||
def cellString(cell):
|
def cellString(cell):
|
||||||
return str(cell).replace("<", " ").replace(">", " ")
|
cell = str(cell)
|
||||||
|
excludeChars = """<>"'[]"""
|
||||||
|
for c in excludeChars:
|
||||||
|
if c in cell:
|
||||||
|
cell = cell.replace(c, "")
|
||||||
|
return cell
|
||||||
|
|
||||||
def td(cell):
|
def td(cell):
|
||||||
return "<td>" + cellString(cell) + "</td>"
|
return "<td>" + cellString(cell) + "</td>"
|
||||||
|
@ -50,3 +55,6 @@ data-export-types="['json', 'xml', 'csv', 'txt', 'sql', 'pdf']">
|
||||||
<hr>
|
<hr>
|
||||||
<br>'''
|
<br>'''
|
||||||
return table
|
return table
|
||||||
|
|
||||||
|
def appointmentDate(date):
|
||||||
|
return date.strftime("%a %d.%m.%Y")
|
||||||
|
|
|
@ -23,8 +23,8 @@ partb2 = Part(label="B/2", semester=sem)
|
||||||
db.session.add(parta1)
|
db.session.add(parta1)
|
||||||
db.session.add(partb2)
|
db.session.add(partb2)
|
||||||
|
|
||||||
g1 = Group(number=1)
|
g1 = Group(number=1, part=parta1)
|
||||||
g2 = Group(number=2)
|
g2 = Group(number=2, part=partb2)
|
||||||
|
|
||||||
db.session.add(g1)
|
db.session.add(g1)
|
||||||
db.session.add(g2)
|
db.session.add(g2)
|
||||||
|
|
Loading…
Reference in a new issue