mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Added active semester default to UserView
This commit is contained in:
parent
6036500f2a
commit
e56aca7545
2 changed files with 7 additions and 1 deletions
|
@ -45,6 +45,9 @@ class UserView(SecureModelView):
|
|||
def semesterQueryFactory():
|
||||
return Semester.query
|
||||
|
||||
def activeSemesterDefault():
|
||||
return userActiveSemester()
|
||||
|
||||
email = TextField("Email", validators=[DataRequired(), Email()])
|
||||
roles = QuerySelectMultipleField(
|
||||
"Roles",
|
||||
|
@ -58,6 +61,7 @@ class UserView(SecureModelView):
|
|||
query_factory=semesterQueryFactory,
|
||||
allow_blank=True,
|
||||
blank_text="-",
|
||||
default=activeSemesterDefault,
|
||||
)
|
||||
|
||||
class EditForm(CreateForm):
|
||||
|
|
|
@ -13,7 +13,9 @@ def randomPassword():
|
|||
|
||||
|
||||
def userActiveSemester(flashWarning=False):
|
||||
lastSemesterId = Semester.query.order_by(Semester.year.desc()).order_by(Semester.label.desc()).first().id
|
||||
lastSemesterId = (
|
||||
Semester.query.order_by(Semester.year.desc()).order_by(Semester.label.desc()).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