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:
parent
6d281dfe3a
commit
d71070008d
1 changed files with 5 additions and 3 deletions
|
@ -17,10 +17,12 @@ def flashRandomPassword(password):
|
|||
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):
|
||||
lastSemesterId = (
|
||||
Semester.query.order_by(Semester.year.desc()).order_by(Semester.label.desc()).first().id
|
||||
) # "WS" > "SS"
|
||||
lastSemesterId = sortedSemestersStartingWithNewest().first().id # "WS" > "SS"
|
||||
if current_user.active_semester_id is None:
|
||||
current_user.active_semester_id = lastSemesterId
|
||||
db.session.commit()
|
||||
|
|
Loading…
Reference in a new issue