mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Small fixes
This commit is contained in:
parent
6d4ac06078
commit
d2ab29b0d3
2 changed files with 5 additions and 8 deletions
|
@ -113,13 +113,12 @@ class Group(db.Model):
|
||||||
semester = part_students[0].part.semester
|
semester = part_students[0].part.semester
|
||||||
program = part_students[0].part.program
|
program = part_students[0].part.program
|
||||||
|
|
||||||
lastTakenGroupNumber = (
|
groupWithHighestNumber = (
|
||||||
Group.query.filter(Group.semester == semester, Group.program == program)
|
Group.query.filter(Group.semester == semester, Group.program == program)
|
||||||
.order_by(Group.number.desc())
|
.order_by(Group.number.desc())
|
||||||
.first()
|
.first()
|
||||||
.number
|
|
||||||
or 0
|
|
||||||
)
|
)
|
||||||
|
lastTakenGroupNumber = (groupWithHighestNumber and groupWithHighestNumber.number) or 0
|
||||||
|
|
||||||
return Group(
|
return Group(
|
||||||
program=program,
|
program=program,
|
||||||
|
@ -358,14 +357,14 @@ class Semester(db.Model):
|
||||||
semester.transferPartsFrom(oldSemester)
|
semester.transferPartsFrom(oldSemester)
|
||||||
|
|
||||||
for experiment in Experiment.query.filter(Experiment.active == True):
|
for experiment in Experiment.query.filter(Experiment.active == True):
|
||||||
newSemesterExperiment = SemesterExperiment(experiment=experiment, semester=model)
|
newSemesterExperiment = SemesterExperiment(experiment=experiment, semester=semester)
|
||||||
|
|
||||||
if transferAssistants:
|
if transferAssistants:
|
||||||
for oldSemesterExperiment in oldSemester.semester_experiments:
|
for oldSemesterExperiment in oldSemester.semester_experiments:
|
||||||
if oldSemesterExperiment.experiment == experiment:
|
if oldSemesterExperiment.experiment == experiment:
|
||||||
newSemesterExperiment.assistants = oldSemesterExperiment.assistants
|
newSemesterExperiment.assistants = oldSemesterExperiment.assistants
|
||||||
|
|
||||||
self.session.add(newSemesterExperiment)
|
db.session.add(newSemesterExperiment)
|
||||||
|
|
||||||
return semester
|
return semester
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,7 @@ def randomPassword():
|
||||||
|
|
||||||
|
|
||||||
def userActiveSemester(flashWarning=False):
|
def userActiveSemester(flashWarning=False):
|
||||||
lastSemesterId = (
|
lastSemesterId = Semester.query.order_by(Semester.year.desc()).order_by(Semester.id.desc()).first().id
|
||||||
Semester.query.order_by(Semester.year).order_by(Semester.id.desc()).first().id
|
|
||||||
) # TODO: Check orders
|
|
||||||
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