From 213d84678587d8d0b3f3b443790be50ba094fc4a Mon Sep 17 00:00:00 2001 From: Krrupa <“sudonthineni@gmail.com@users.noreply.github.com”> Date: Mon, 22 Jan 2024 16:07:38 +0530 Subject: [PATCH] testing --- app/id_generation.py | 34 ++++++++++++++++++---------------- app/router/student.py | 4 +--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/id_generation.py b/app/id_generation.py index ed5b33d..45f580c 100644 --- a/app/id_generation.py +++ b/app/id_generation.py @@ -88,25 +88,27 @@ def dedupe_for_users(parameters): } ) ) - - # check if any of the found students study in the school - for student in does_student_already_exist: - does_enrollment_record_exist = ( - enrollment_record.get_enrollment_record( - build_request( - query_params={ - "school_id": school_id_response[0]["id"], - "student_id": student["id"], - "grade": parameters["grade"], - } + if len(school_id_response) > 0: + # check if any of the found students study in the school + for student in does_student_already_exist: + does_enrollment_record_exist = ( + enrollment_record.get_enrollment_record( + build_request( + query_params={ + "school_id": school_id_response["id"], + "student_id": student["id"], + "grade": parameters["grade"], + } + ) ) ) - ) - if len(does_enrollment_record_exist) == 0: - return [False, ""] - else: - return [True, student["student_id"]] + if len(does_enrollment_record_exist) == 0: + return [False, ""] + else: + return [True, student["student_id"]] + else: + raise HTTPException(status_code=404, detail="School does not exist!") def get_class_code(grade): diff --git a/app/router/student.py b/app/router/student.py index 1cca1c9..2db0cc3 100644 --- a/app/router/student.py +++ b/app/router/student.py @@ -358,12 +358,11 @@ async def create_student(request: Request): group_data = group.get_group_data( build_request(query_params={"name": data["group"]}) ) - # get group-type ID response = requests.get( routes.group_type_db_url, params={ - "child_id": group_data[0]["id"], + "child_id": group_data["id"], "type": "group", }, headers=db_request_token(), @@ -394,7 +393,6 @@ async def create_student(request: Request): } ) ) - query_params["school_id"] = school_id_response[0]["id"] # create a new enrollment record for the student, based on the student ID and school ID