ECOM-1162

This commit is contained in:
Awais
2015-03-13 22:56:25 +05:00
parent 40ae5d2e1c
commit 3a996155f5
3 changed files with 90 additions and 27 deletions

View File

@@ -710,6 +710,25 @@ class CourseEnrollment(models.Model):
return enrollment
@classmethod
def get_enrollment(cls, user, course_key):
"""Returns a CoursewareEnrollment object.
Args:
user (User): The user associated with the enrollment.
course_id (CourseKey): The key of the course associated with the enrollment.
Returns:
Course enrollment object or None
"""
try:
return CourseEnrollment.objects.get(
user=user,
course_id=course_key
)
except cls.DoesNotExist:
return None
@classmethod
def num_enrolled_in(cls, course_id):
"""