Skip to content

Commit

Permalink
Merge pull request #828
Browse files Browse the repository at this point in the history
* stv/enrollment-api/cleanup:
  Consolidate enrollment_api code
  • Loading branch information
stvstnfrd committed Oct 23, 2018
2 parents 22a86e9 + bf8fc7c commit 0218a63
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions openedx/stanford/common/djangoapps/enrollment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)

0 comments on commit 0218a63

Please sign in to comment.