add external_user_key to response and add ability to search by username, email, or external user key

Code review comments - EDUCATOR-4319

undoing changes temporarily

undoing changes temporarily

Fixed exception handling

re-added changes after hard reset

removed waffle flag (wrong merge

removed waffle flag (wrong merge
This commit is contained in:
Michael Roytman
2019-06-07 11:18:26 -04:00
committed by atesker
parent dff3eec0d1
commit 05c0510cd3
8 changed files with 197 additions and 39 deletions

View File

@@ -1244,6 +1244,26 @@ class CourseEnrollment(models.Model):
except cls.DoesNotExist:
return None
@classmethod
def get_program_enrollment(cls, user, course_id):
"""
Return the ProgramEnrollment associated with the CourseEnrollment specified
by the user and course_id.
Return None if there is no ProgramEnrollment.
Arguments:
user (User): the user for whom we want the program enrollment
coure_id (CourseKey): the id of the course the user has a course enrollment in
Returns:
ProgramEnrollment object or None
"""
try:
course_enrollment = cls.objects.get(user=user, course_id=course_id)
return course_enrollment.programcourseenrollment.program_enrollment
except (ObjectDoesNotExist):
return None
@classmethod
def is_enrollment_closed(cls, user, course):
"""