diff --git a/advlabdb/dependent_funs.py b/advlabdb/dependent_funs.py index 605bda3..5826e6e 100644 --- a/advlabdb/dependent_funs.py +++ b/advlabdb/dependent_funs.py @@ -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): diff --git a/advlabdb/scripts/setup/init_database.py b/advlabdb/scripts/setup/init_database.py index 9b91402..9a5629d 100644 --- a/advlabdb/scripts/setup/init_database.py +++ b/advlabdb/scripts/setup/init_database.py @@ -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.")