Commit 9eaf7206 by Alan Boudreault Committed by Jonathan Piacenti

Reverted a minor change in get_cohort to fix failing test in course_groups

parent e9491d59
...@@ -20,7 +20,6 @@ from courseware.model_data import FieldDataCache ...@@ -20,7 +20,6 @@ from courseware.model_data import FieldDataCache
from openedx.core.djangoapps.course_groups.models import CourseUserGroup from openedx.core.djangoapps.course_groups.models import CourseUserGroup
from openedx.core.djangoapps.course_groups.cohorts import ( from openedx.core.djangoapps.course_groups.cohorts import (
get_cohort_by_name, get_cohort_by_name,
get_cohort,
add_cohort, add_cohort,
add_user_to_cohort, add_user_to_cohort,
remove_user_from_cohort remove_user_from_cohort
...@@ -903,9 +902,15 @@ class UsersCoursesDetail(SecureAPIView): ...@@ -903,9 +902,15 @@ class UsersCoursesDetail(SecureAPIView):
if not course_exists(request, user, course_id): if not course_exists(request, user, course_id):
return Response({}, status=status.HTTP_204_NO_CONTENT) return Response({}, status=status.HTTP_204_NO_CONTENT)
course_key = get_course_key(course_id) course_key = get_course_key(course_id)
cohort = get_cohort(user, course_key) try:
if cohort: cohort = CourseUserGroup.objects.get(
course_id=course_key,
users__id=user.id,
group_type=CourseUserGroup.COHORT,
)
remove_user_from_cohort(cohort, user.username) remove_user_from_cohort(cohort, user.username)
except ObjectDoesNotExist:
pass
CourseEnrollment.unenroll(user, course_key) CourseEnrollment.unenroll(user, course_key)
return Response({}, status=status.HTTP_204_NO_CONTENT) return Response({}, status=status.HTTP_204_NO_CONTENT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment