Merge pull request #17554 from edx/sofiya/2095-3

Check that a user enrollment exists in the course outline
This commit is contained in:
Sofiya Semenova
2018-02-27 13:10:20 -05:00
committed by GitHub

View File

@@ -141,7 +141,13 @@ class CourseOutlineFragmentView(EdxFragmentView):
check until all active enrollments are created after the date.
"""
begin_collection_date = datetime.datetime(2018, 01, 24, tzinfo=pytz.utc)
user_enrollment = CourseEnrollment.get_enrollment(user=user, course_key=course_key)
if user_enrollment and user_enrollment.is_active and user_enrollment.created > begin_collection_date:
return True
return False
user = User.objects.get(username=user)
try:
user_enrollment = CourseEnrollment.objects.get(
user=user,
course_id=course_key,
is_active=True
)
return user_enrollment.created > begin_collection_date
except CourseEnrollment.DoesNotExist:
return False