Skip to content

Commit cc08bc7

Browse files
committed
fix: update the platform import that has changed
This replaces the import of `students_update_enrollment` with `StudentsUpdateEnrollmentView` in views.py. The original function was refactored into a DRF APIView in openedx/openedx-platform@cdf5083 This commit updated the relevant code and it's usage to match this change. Internal-ref: https://tasks.opencraft.com/browse/BB-10583
1 parent 99faef2 commit cc08bc7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

shoppingcart/views.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Views for the API"""
22

3-
import json
43
import logging
54
import secrets
65
import string
@@ -30,7 +29,7 @@
3029
from lms.djangoapps.certificates.models import GeneratedCertificate
3130
from lms.djangoapps.course_api.api import list_courses
3231
from lms.djangoapps.course_api.serializers import CourseSerializer
33-
from lms.djangoapps.instructor.views.api import students_update_enrollment
32+
from lms.djangoapps.instructor.views.api import StudentsUpdateEnrollmentView
3433
from opaque_keys.edx.keys import CourseKey
3534
from openedx.core.djangoapps.enrollments.views import (
3635
ApiKeyPermissionMixIn,
@@ -402,19 +401,20 @@ class BulkEnrollView(APIView, ApiKeyPermissionMixIn):
402401
def post(self, request):
403402
serializer = BulkEnrollmentSerializer(data=request.data)
404403
if serializer.is_valid():
405-
request._request.POST = request.data # pylint: disable=protected-access
406404
response_dict = {
407405
"auto_enroll": serializer.data.get("auto_enroll"),
408406
"email_students": serializer.data.get("email_students"),
409407
"action": serializer.data.get("action"),
410408
"courses": {},
411409
}
410+
view = StudentsUpdateEnrollmentView()
412411
for course in serializer.data.get("courses"):
413-
response = students_update_enrollment(
414-
request._request, # pylint: disable=protected-access
412+
response_dict["courses"][course] = view._process_student_enrollment( # pylint: disable=protected-access
413+
user=request.user,
415414
course_id=course,
415+
data=request.data,
416+
secure=request.is_secure(),
416417
)
417-
response_dict["courses"][course] = json.loads(response.content.decode("utf-8"))
418418
return Response(data=response_dict, status=status.HTTP_200_OK)
419419
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
420420

0 commit comments

Comments
 (0)