mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Catch error while initializing the database
This commit is contained in:
parent
669d45606a
commit
d5dff6ccda
2 changed files with 15 additions and 9 deletions
|
@ -51,17 +51,22 @@ def setUserActiveSemester(semesterId):
|
|||
|
||||
def initActiveSemesterMenuLinks(space):
|
||||
with app.app_context():
|
||||
semesters = Semester.query.order_by(Semester.id.desc())
|
||||
for semester in semesters:
|
||||
space.add_link(
|
||||
MenuLink(
|
||||
name=semester.repr(),
|
||||
url=url_for("set_semester") + "?semester_id=" + str(semester.id),
|
||||
category="Active semester",
|
||||
try:
|
||||
semesters = Semester.query.order_by(Semester.id.desc())
|
||||
for semester in semesters:
|
||||
space.add_link(
|
||||
MenuLink(
|
||||
name=semester.repr(),
|
||||
url=url_for("set_semester") + "?semester_id=" + str(semester.id),
|
||||
category="Active semester",
|
||||
)
|
||||
)
|
||||
except Exception as ex:
|
||||
print(
|
||||
"ERROR: The Semester table does not exist yet! Therefore, menu links could not be generated. You can ignore this error if you are just initializing the database."
|
||||
)
|
||||
|
||||
space.add_link(MenuLink(name="Logout", url=url_for("security.logout")))
|
||||
else:
|
||||
space.add_link(MenuLink(name="Logout", url=url_for("security.logout")))
|
||||
|
||||
|
||||
def reportBadAttempt(message):
|
||||
|
|
|
@ -8,6 +8,7 @@ from ..terminal_utils import box, confirm, validating_input
|
|||
|
||||
|
||||
def main():
|
||||
print("\n")
|
||||
print("This script should only be used to initialize the database after setting up a server")
|
||||
print("The old database will be DELETED and a new database will be created.")
|
||||
|
||||
|
|
Loading…
Reference in a new issue