mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
highestGroupNumber
This commit is contained in:
parent
5627b88051
commit
659156b749
1 changed files with 11 additions and 5 deletions
|
@ -11,6 +11,7 @@ from decimal import ROUND_HALF_UP, Decimal
|
|||
from flask import flash
|
||||
from flask_security import current_user
|
||||
from flask_security.models.fsqla_v2 import FsRoleMixin, FsUserMixin
|
||||
from sqlalchemy import select
|
||||
|
||||
from . import db
|
||||
from .configUtils import getConfig
|
||||
|
@ -170,14 +171,19 @@ class Group(db.Model):
|
|||
semester = part_students[0].part.semester
|
||||
program = part_students[0].part.program
|
||||
|
||||
groupWithHighestNumber = (
|
||||
Group.query.filter(Group.semester == semester, Group.program == program)
|
||||
.order_by(Group.number.desc())
|
||||
highestGroupNumber = (
|
||||
db.session.execute(
|
||||
select(Group.number)
|
||||
.where(Group.semester == semester, Group.program == program)
|
||||
.order_by(Group.number.desc())
|
||||
.limit(1)
|
||||
)
|
||||
.scalars()
|
||||
.first()
|
||||
)
|
||||
|
||||
if groupWithHighestNumber is not None:
|
||||
number = groupWithHighestNumber.number + 1
|
||||
if highestGroupNumber is not None:
|
||||
number = highestGroupNumber + 1
|
||||
else:
|
||||
number = 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue