Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
suryabulusu committed Sep 9, 2024
2 parents af9ccf9 + bdd9087 commit 817f4da
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
22 changes: 21 additions & 1 deletion app/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@

GROUP_USER_QUERY_PARAMS = ["id", "group_id", "user_id"]

SCHOOL_QUERY_PARAMS = ["id", "name", "school_name", "code", "board_medium", "region"]
SCHOOL_QUERY_PARAMS = [
"id",
"name",
"school_name",
"code",
"board_medium",
"region",
"district",
"state",
]

SESSION_QUERY_PARAMS = ["id", "name", "session_id"]

Expand Down Expand Up @@ -94,3 +103,14 @@
"date_of_birth",
"country",
]

authgroup_state_mapping = {
"HaryanaStudents": "Haryana",
"DelhiStudents": "Delhi",
"UttarakhandStudents": "Uttarakhand",
"GujaratStudents": "Gujarat",
"HimachalStudents": "Himachal Pradesh",
"PunjabStudents": "Punjab",
"MaharashtraStudents": "Maharashtra",
"TNStudents": "Tamil Nadu",
}
34 changes: 27 additions & 7 deletions app/router/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
STUDENT_QUERY_PARAMS,
ENROLLMENT_RECORD_PARAMS,
SCHOOL_QUERY_PARAMS,
authgroup_state_mapping,
)

router = APIRouter(prefix="/student", tags=["Student"])
Expand Down Expand Up @@ -46,10 +47,26 @@ def build_student_and_user_data(student_data):
return data


async def create_school_user_record(data, school_name):
school_data = school.get_school(
build_request(query_params={"name": str(school_name)})
)
async def create_school_user_record(data, school_name, district, auth_group_name):
state = authgroup_state_mapping.get(auth_group_name, "")

if state:
school_data = school.get_school(
build_request(
query_params={
"name": str(school_name),
"district": str(district),
"state": state,
}
)
)
else:
school_data = school.get_school(
build_request(
query_params={"name": str(school_name), "district": str(district)}
)
)

group_data = group.get_group(
build_request(query_params={"child_id": school_data["id"], "type": "school"})
)
Expand Down Expand Up @@ -283,9 +300,12 @@ async def create_student(request: Request):
await create_auth_group_user_record(new_student_data, data["auth_group"])

if "school_name" in query_params:

await create_school_user_record(new_student_data, query_params["school_name"])

await create_school_user_record(
new_student_data,
query_params["school_name"],
query_params["district"],
data["auth_group"],
)
return student_id


Expand Down

0 comments on commit 817f4da

Please sign in to comment.