2021-03-18 22:20:59 +00:00
|
|
|
def navbarItems(activePage):
|
2021-03-20 14:41:22 +00:00
|
|
|
pages = ["Students", "Assistants", "Experiments", "Appointments", "Groups", "Users", "Semesters"]
|
|
|
|
items = []
|
2021-03-18 22:20:59 +00:00
|
|
|
for page in pages:
|
|
|
|
active = ""
|
|
|
|
lowerPage = page.lower().replace(" ", "_")
|
|
|
|
if lowerPage == activePage:
|
|
|
|
active = " active"
|
2021-03-20 14:41:22 +00:00
|
|
|
items.append('<a class="nav-link' + active + '" href="' + lowerPage + '">' + page + '</a>')
|
2021-03-18 22:20:59 +00:00
|
|
|
return items
|
2021-03-19 12:41:52 +00:00
|
|
|
|
2021-03-19 15:30:02 +00:00
|
|
|
def makeTable(headerAndDataList, rows):
|
2021-03-19 17:09:07 +00:00
|
|
|
def cellString(cell):
|
2021-03-19 20:15:43 +00:00
|
|
|
cell = str(cell)
|
2021-03-20 14:41:22 +00:00
|
|
|
if cell == "[]":
|
|
|
|
return "<em>None</em>"
|
|
|
|
|
2021-03-19 20:15:43 +00:00
|
|
|
excludeChars = """<>"'[]"""
|
|
|
|
for c in excludeChars:
|
|
|
|
if c in cell:
|
|
|
|
cell = cell.replace(c, "")
|
|
|
|
return cell
|
2021-03-19 17:09:07 +00:00
|
|
|
|
2021-03-19 15:30:02 +00:00
|
|
|
def td(cell):
|
2021-03-19 17:09:07 +00:00
|
|
|
return "<td>" + cellString(cell) + "</td>"
|
2021-03-19 12:41:52 +00:00
|
|
|
|
2021-03-19 15:30:02 +00:00
|
|
|
def th(cell):
|
2021-03-19 17:09:07 +00:00
|
|
|
return '<th data-sortable="true">' + cellString(cell) + '</th>'
|
|
|
|
|
|
|
|
table = '''<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']">
|
|
|
|
<thead>
|
|
|
|
<tr>'''
|
2021-03-19 15:30:02 +00:00
|
|
|
for i in headerAndDataList:
|
|
|
|
table += th(i[0])
|
2021-03-19 17:09:07 +00:00
|
|
|
table += '''</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>\n'''
|
2021-03-19 15:30:02 +00:00
|
|
|
|
|
|
|
for row in rows:
|
|
|
|
table += '<tr>'
|
|
|
|
|
|
|
|
for i in headerAndDataList:
|
|
|
|
table += td(eval(i[1]))
|
|
|
|
|
|
|
|
table += '</tr>\n'
|
|
|
|
|
2021-03-19 17:09:07 +00:00
|
|
|
table += '''</tbody>
|
|
|
|
</table>
|
|
|
|
<br>
|
|
|
|
<hr>
|
|
|
|
<br>'''
|
2021-03-19 15:30:02 +00:00
|
|
|
return table
|
2021-03-19 20:15:43 +00:00
|
|
|
|
|
|
|
def appointmentDate(date):
|
|
|
|
return date.strftime("%a %d.%m.%Y")
|