From bf8fc7c5c663630c8225a16fca6a84e5fc9cb154 Mon Sep 17 00:00:00 2001 From: stv Date: Thu, 13 Sep 2018 14:00:26 -0700 Subject: [PATCH] Consolidate enrollment_api code These functions were really only 1 line long and each only used once, so let's just inline them. --- .../common/djangoapps/enrollment/views.py | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/openedx/stanford/common/djangoapps/enrollment/views.py b/openedx/stanford/common/djangoapps/enrollment/views.py index e0a8a50e56ea..b3d63b874fe1 100644 --- a/openedx/stanford/common/djangoapps/enrollment/views.py +++ b/openedx/stanford/common/djangoapps/enrollment/views.py @@ -31,19 +31,6 @@ from openedx.stanford.common.djangoapps.enrollment.data import get_roster -def _enroll(course_key, email, auto_enroll, email_students, email_params, language): - enroll_email( - course_key, email, auto_enroll, email_students, email_params, language=language - ) - return Response(status=status.HTTP_204_NO_CONTENT) - -def _unenroll(course_key, email, email_students, email_params, language): - unenroll_email( - course_key, email, email_students, email_params, language=language - ) - return Response(status=status.HTTP_204_NO_CONTENT) - - class EnrollmentRosterView(APIView, ApiKeyPermissionMixIn): """ Read roster for a particular course. (contains PII) @@ -127,7 +114,10 @@ def put(self, request, course_id): if User.objects.filter(email=email).exists(): user = User.objects.get(email=email) language = get_user_email_language(user) - return _enroll(course_key, email, auto_enroll, email_students, email_params, language) + enroll_email( + course_key, email, auto_enroll, email_students, email_params, language=language + ) + return Response(status=status.HTTP_204_NO_CONTENT) def delete(self, request, course_id): """ @@ -179,4 +169,7 @@ def delete(self, request, course_id): if User.objects.filter(email=email).exists(): user = User.objects.get(email=email) language = get_user_email_language(user) - return _unenroll(course_key, email, email_students, email_params, language) + unenroll_email( + course_key, email, email_students, email_params, language=language + ) + return Response(status=status.HTTP_204_NO_CONTENT)