Skip to content

Commit

Permalink
Consolidate enrollment_api code
Browse files Browse the repository at this point in the history
These functions were really only 1 line long and each only used once,
so let's just inline them.
  • Loading branch information
stvstnfrd committed Sep 13, 2018
1 parent 14c26a1 commit bf8fc7c
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 bf8fc7c

Please sign in to comment.