'Create an enrollment for a user in a class. By default *this enrollment
is not active*. This is useful for when an enrollment needs to go
through some sort of approval process before being activated. If you
don\'t need this functionality, just call `enroll()` instead.
Returns a CoursewareEnrollment object.
`user` is a Django User object. If it hasn\'t been saved yet (no `.id`
attribute), this method will automatically save it before
adding an enrollment for it.
`course_id` is our usual course_id string (e.g. "edX/Test101/2013_Fall)
It is expected that this method is called from a method which has already
verified the user authentication and access.'

@classmethod
def get_or_create_enrollment(cls, user, course_key):

    assert isinstance(course_key, CourseKey)
    if (user.id is None):
        user.save()
    (enrollment, __) = cls.objects.get_or_create(user=user, course_id=course_key, defaults={'mode': CourseMode.DEFAULT_MODE_SLUG, 'is_active': False})
    return enrollment
