Merge branch 'master' of https://git.wmi.amu.edu.pl/s459309/system-pri
This commit is contained in:
commit
5a49e87a63
@ -50,6 +50,13 @@ def create_group(data: dict) -> dict:
|
||||
# elif result <= 0:
|
||||
# abort(400, "Can't create new group, project supervisor achieved a limit of groups")
|
||||
|
||||
project_supervisor = ProjectSupervisor.query.filter_by(id=project_supervisor_id).first()
|
||||
|
||||
if project_supervisor is None:
|
||||
abort(400, "Project Supervisor with id {project_supervisor_id} doesnt exist")
|
||||
elif project_supervisor.limit_group == project_supervisor.count_groups:
|
||||
abort(400, "Can't create new group, project supervisor achieved a limit of groups")
|
||||
|
||||
group = Group(name=name, project_supervisor_id=project_supervisor_id)
|
||||
|
||||
students_without_groups = db.session.query(Student).join(Group, isouter=True) \
|
||||
@ -59,6 +66,7 @@ def create_group(data: dict) -> dict:
|
||||
abort(400, "One or more students have already belonged to group!")
|
||||
|
||||
students = db.session.query(Student).filter(Student.index.in_(students_indexes)).all()
|
||||
project_supervisor.count_groups += 1
|
||||
for student in students:
|
||||
student.group_id = group.id
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user