diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index 1553395..46fccd5 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -1194,7 +1194,7 @@ class AppointmentView(SecureAdminModelView): class ExperimentMarkView(SecureAdminModelView): class StudentFilter(FilterEqual): def validate(self, value): - if Student.query.get(value): + if db.session.get(Student, value) is not None: return True else: return False diff --git a/advlabdb/dependent_funs.py b/advlabdb/dependent_funs.py index 5826e6e..d4504f4 100644 --- a/advlabdb/dependent_funs.py +++ b/advlabdb/dependent_funs.py @@ -20,8 +20,8 @@ def userActiveSemester(flashWarning=False): current_user.active_semester_id = lastSemesterId db.session.commit() elif current_user.active_semester_id != lastSemesterId: - activeSemester = Semester.query.get(current_user.active_semester_id) - if activeSemester: + activeSemester = db.session.get(Semester, current_user.active_semester_id) + if activeSemester is not None: if flashWarning: flash(f"You are in the old semester {activeSemester.repr()}!", "warning") else: @@ -29,13 +29,13 @@ def userActiveSemester(flashWarning=False): db.session.commit() flash("Semester changed!", "warning") - return Semester.query.get(current_user.active_semester_id) + return db.session.get(Semester, current_user.active_semester_id) def setUserActiveSemester(semesterId): if current_user.active_semester_id != semesterId: - semester = Semester.query.get(semesterId) - if semester: + semester = db.session.get(Semester, semesterId) + if semester is not None: try: current_user.active_semester_id = semesterId db.session.commit()