Skip to content

Commit

Permalink
fixing issue with of delete action
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 committed Nov 27, 2024
1 parent 47a9411 commit 26f028f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import random
import re


import dateutil
import pytz
import edx_api_doc_tools as apidocs
Expand All @@ -22,7 +23,7 @@
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist, PermissionDenied, ValidationError
from django.core.validators import validate_email
from django.db import IntegrityError, transaction
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound
from django.http import QueryDict, HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.decorators import method_decorator
Expand Down Expand Up @@ -3335,6 +3336,7 @@ def _handle_certificate_exception(self, request, course_id, action):
"""
Handles adding or removing certificate exceptions.
"""
breakpoint()
course_key = CourseKey.from_string(course_id)
try:
data = request.data
Expand Down Expand Up @@ -3367,6 +3369,13 @@ def _get_and_validate_user(self, raw_data):
"""
Extracts the user data from the request and validates the student.
"""
if isinstance(raw_data, QueryDict): # its only happening in case of delete from front-end
raw_data = list(raw_data.keys())[0]
try:
raw_data = json.loads(raw_data)
except Exception as error: # pylint: disable=broad-except
return None, JsonResponse({'success': False, 'message': str(error)}, status=400)

try:
user_data = raw_data.get('user_name', '') or raw_data.get('user_email', '')
except ValueError as error:
Expand Down

0 comments on commit 26f028f

Please sign in to comment.