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

Add sorted semesters function

This commit is contained in:
Mo 2022-04-12 15:00:12 +02:00
parent 6d281dfe3a
commit d71070008d

View file

@ -17,10 +17,12 @@ def flashRandomPassword(password):
flash(f"Random password: {password}", category="warning") flash(f"Random password: {password}", category="warning")
def sortedSemestersStartingWithNewest():
return Semester.query.order_by(Semester.year.desc()).order_by(Semester.label.desc())
def userActiveSemester(flashWarning=False): def userActiveSemester(flashWarning=False):
lastSemesterId = ( lastSemesterId = sortedSemestersStartingWithNewest().first().id # "WS" > "SS"
Semester.query.order_by(Semester.year.desc()).order_by(Semester.label.desc()).first().id
) # "WS" > "SS"
if current_user.active_semester_id is None: if current_user.active_semester_id is None:
current_user.active_semester_id = lastSemesterId current_user.active_semester_id = lastSemesterId
db.session.commit() db.session.commit()