Skip to content

Commit

Permalink
Merge pull request #1948 from jelanmathewjames/dev
Browse files Browse the repository at this point in the history
fix: key error
  • Loading branch information
jelanmathewjames authored May 14, 2024
2 parents f24b2c1 + 398313e commit 78d44f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/integrations/wadhwani/wadhwani_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def post(self, request):
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
response = requests.post(url, data=data, headers=headers)

if response.json()["status"] == "ERROR":
if response.json().get("error", None):
return CustomResponse(general_message="Invalid credentials").get_failure_response()
return CustomResponse(response=response.json()).get_success_response()

Expand Down Expand Up @@ -47,7 +47,7 @@ def post(self, request):
}
response = requests.post(url, data=data)

if response.json()["status"] == "ERROR":
if response.json().get("status", None) == "ERROR":
return CustomResponse(general_message="Invalid Input").get_failure_response()
return CustomResponse(response=response.json()).get_success_response()

Expand All @@ -61,7 +61,7 @@ def post(self, request):
headers = {'Authorization': token}
response = requests.get(url, headers=headers)

if response.json()["status"] == "ERROR":
if response.json().get("status", None) == "ERROR":
return CustomResponse(general_message="No courses available").get_failure_response()
return CustomResponse(response=response.json()).get_success_response()

Expand All @@ -77,7 +77,7 @@ def post(self, request):
headers = {'Authorization': token}
response = requests.get(url, params={"username": user.email}, headers=headers)

if response.json()["status"] == "ERROR":
if response.json().get("status", None) == "ERROR":
return CustomResponse(general_message="User doesn't have any enrolled courses").get_failure_response()
return CustomResponse(response=response.json()).get_success_response()

Expand All @@ -95,6 +95,6 @@ def post(self, request):
url = settings.WADHWANI_BASE_URL + f"/api/v1/courseservice/oauth/course/{course_id}/reports/quiz/student/{user.email}"
response = requests.get(url, headers=headers)

if response.json()["status"] == "ERROR":
if response.json().get("status", None) == "ERROR":
return CustomResponse(general_message="No quiz data available").get_failure_response()
return CustomResponse(response=response.json()).get_success_response()

0 comments on commit 78d44f5

Please sign in to comment.