Merge branch 'release'

This commit is contained in:
Sarina Canelake
2014-06-11 21:30:05 -04:00
12 changed files with 133 additions and 26 deletions

View File

@@ -889,18 +889,15 @@ class CourseEnrollment(models.Model):
`user` is a Django User object
`course_id` is our usual course_id string (e.g. "edX/Test101/2013_Fall)
Returns the mode for both inactive and active users.
Returns None if the courseenrollment record does not exist.
Returns (mode, is_active) where mode is the enrollment mode of the student
and is_active is whether the enrollment is active.
Returns (None, None) if the courseenrollment record does not exist.
"""
try:
record = CourseEnrollment.objects.get(user=user, course_id=course_id)
if hasattr(record, 'mode'):
return record.mode
else:
return None
return (record.mode, record.is_active)
except cls.DoesNotExist:
return None
return (None, None)
@classmethod
def enrollments_for_user(cls, user):

View File

@@ -10,6 +10,7 @@ import factory
from factory.django import DjangoModelFactory
from uuid import uuid4
from pytz import UTC
from xmodule.modulestore.locations import SlashSeparatedCourseKey
# Factories don't have __init__ methods, and are self documenting
# pylint: disable=W0232, C0111
@@ -109,14 +110,14 @@ class CourseEnrollmentFactory(DjangoModelFactory):
FACTORY_FOR = CourseEnrollment
user = factory.SubFactory(UserFactory)
course_id = u'edX/toy/2012_Fall'
course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
class CourseEnrollmentAllowedFactory(DjangoModelFactory):
FACTORY_FOR = CourseEnrollmentAllowed
email = 'test@edx.org'
course_id = 'edX/test/2012_Fall'
course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
class PendingEmailChangeFactory(DjangoModelFactory):