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

highestGroupNumber

This commit is contained in:
Mo 2022-05-16 18:57:21 +02:00
parent 5627b88051
commit 659156b749

View file

@ -11,6 +11,7 @@ from decimal import ROUND_HALF_UP, Decimal
from flask import flash from flask import flash
from flask_security import current_user from flask_security import current_user
from flask_security.models.fsqla_v2 import FsRoleMixin, FsUserMixin from flask_security.models.fsqla_v2 import FsRoleMixin, FsUserMixin
from sqlalchemy import select
from . import db from . import db
from .configUtils import getConfig from .configUtils import getConfig
@ -170,14 +171,19 @@ 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
groupWithHighestNumber = ( highestGroupNumber = (
Group.query.filter(Group.semester == semester, Group.program == program) db.session.execute(
.order_by(Group.number.desc()) select(Group.number)
.where(Group.semester == semester, Group.program == program)
.order_by(Group.number.desc())
.limit(1)
)
.scalars()
.first() .first()
) )
if groupWithHighestNumber is not None: if highestGroupNumber is not None:
number = groupWithHighestNumber.number + 1 number = highestGroupNumber + 1
else: else:
number = 1 number = 1