From f4f0d379feba67a629daa99bdc46ddbcf25a117d Mon Sep 17 00:00:00 2001 From: Jaimyn Mayer Date: Sat, 6 Jan 2024 19:39:08 +1000 Subject: [PATCH] fixed another canvas api change --- memberportal/api_billing/views.py | 2 ++ memberportal/services/canvas.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/memberportal/api_billing/views.py b/memberportal/api_billing/views.py index b25f289a..d053e97d 100644 --- a/memberportal/api_billing/views.py +++ b/memberportal/api_billing/views.py @@ -398,6 +398,7 @@ def post(self, request): canvas_api = Canvas() except OperationalError as error: capture_exception(error) + logger.error(error) return Response({"success": False, "score": 0}) score = ( @@ -419,6 +420,7 @@ def post(self, request): except Exception as e: capture_exception(e) + logger.error(e) return Response({"success": False, "score": 0, "error": str(e)}) diff --git a/memberportal/services/canvas.py b/memberportal/services/canvas.py index 8ec9ff95..19c48a7c 100644 --- a/memberportal/services/canvas.py +++ b/memberportal/services/canvas.py @@ -12,7 +12,7 @@ def __init__(self): def _get(self, url): r = requests.get( self.base_url + url, - headers={"Authorization": "Bearer " + self.api_token}, + headers={"Authorization": f"Bearer {self.api_token}"}, ) return r.json() @@ -20,7 +20,7 @@ def _get(self, url): def _query_graph(self, query): response = requests.post( self.graphql_url, - headers={"Authorization": "Bearer " + self.api_token}, + headers={"Authorization": f"Bearer {self.api_token}"}, data=query, ) @@ -33,9 +33,9 @@ def get_course_details(self, course_id): :return: """ query = { - "query": "query MyQuery {course(id: " + "query": 'query MyQuery {course(id: "' + str(course_id) - + ") {enrollmentsConnection {nodes {user {email}grades {finalScore}}}}}", + + '") {enrollmentsConnection {nodes {user {email}grades {finalScore}}}}}', } return self._query_graph(query)