mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +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):
|
def initActiveSemesterMenuLinks(space):
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
semesters = Semester.query.order_by(Semester.id.desc())
|
try:
|
||||||
for semester in semesters:
|
semesters = Semester.query.order_by(Semester.id.desc())
|
||||||
space.add_link(
|
for semester in semesters:
|
||||||
MenuLink(
|
space.add_link(
|
||||||
name=semester.repr(),
|
MenuLink(
|
||||||
url=url_for("set_semester") + "?semester_id=" + str(semester.id),
|
name=semester.repr(),
|
||||||
category="Active semester",
|
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."
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
space.add_link(MenuLink(name="Logout", url=url_for("security.logout")))
|
space.add_link(MenuLink(name="Logout", url=url_for("security.logout")))
|
||||||
|
|
||||||
|
|
||||||
def reportBadAttempt(message):
|
def reportBadAttempt(message):
|
||||||
|
|
|
@ -8,6 +8,7 @@ from ..terminal_utils import box, confirm, validating_input
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
print("\n")
|
||||||
print("This script should only be used to initialize the database after setting up a server")
|
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.")
|
print("The old database will be DELETED and a new database will be created.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue