diff --git a/backend/app/coordinator/routes/groups.py b/backend/app/coordinator/routes/groups.py index b8a0905..5b10e63 100644 --- a/backend/app/coordinator/routes/groups.py +++ b/backend/app/coordinator/routes/groups.py @@ -60,13 +60,13 @@ def create_group(data: dict) -> dict: if students_without_groups != len(students_indexes): abort(400, "One or more students have already belonged to group!") + db.session.add(group) + db.session.commit() + 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 - db.session.add_all(students) - db.session.add(group) db.session.commit() return {"message": "Project Supervisor was created!"}