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")
|
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()
|
||||||
|
|
Loading…
Reference in a new issue