From 980cf5da50b119bbc92e5759a88e265aee0d38bf Mon Sep 17 00:00:00 2001 From: dominik24c Date: Mon, 13 Jun 2022 21:47:12 +0200 Subject: [PATCH] update create groups endpoint - fixing errors when adding students to the group --- backend/app/coordinator/routes/groups.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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!"}