1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Use session.get

This commit is contained in:
Mo 2022-05-16 16:56:24 +02:00
parent ec3664a30a
commit d2a0700f7d
2 changed files with 6 additions and 6 deletions

View file

@ -1194,7 +1194,7 @@ class AppointmentView(SecureAdminModelView):
class ExperimentMarkView(SecureAdminModelView): class ExperimentMarkView(SecureAdminModelView):
class StudentFilter(FilterEqual): class StudentFilter(FilterEqual):
def validate(self, value): def validate(self, value):
if Student.query.get(value): if db.session.get(Student, value) is not None:
return True return True
else: else:
return False return False

View file

@ -20,8 +20,8 @@ def userActiveSemester(flashWarning=False):
current_user.active_semester_id = lastSemesterId current_user.active_semester_id = lastSemesterId
db.session.commit() db.session.commit()
elif current_user.active_semester_id != lastSemesterId: elif current_user.active_semester_id != lastSemesterId:
activeSemester = Semester.query.get(current_user.active_semester_id) activeSemester = db.session.get(Semester, current_user.active_semester_id)
if activeSemester: if activeSemester is not None:
if flashWarning: if flashWarning:
flash(f"You are in the old semester {activeSemester.repr()}!", "warning") flash(f"You are in the old semester {activeSemester.repr()}!", "warning")
else: else:
@ -29,13 +29,13 @@ def userActiveSemester(flashWarning=False):
db.session.commit() db.session.commit()
flash("Semester changed!", "warning") 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): def setUserActiveSemester(semesterId):
if current_user.active_semester_id != semesterId: if current_user.active_semester_id != semesterId:
semester = Semester.query.get(semesterId) semester = db.session.get(Semester, semesterId)
if semester: if semester is not None:
try: try:
current_user.active_semester_id = semesterId current_user.active_semester_id = semesterId
db.session.commit() db.session.commit()