Changed create_enrollment to create_or_update_enrollment

This commit is contained in:
Julia Hansbrough
2013-11-08 19:01:51 +00:00
parent de8b378dd9
commit 73af5d017e
3 changed files with 4 additions and 4 deletions

View File

@@ -713,7 +713,7 @@ class CourseEnrollment(models.Model):
).format(self.user, self.course_id, self.created, self.is_active)
@classmethod
def create_enrollment(cls, user, course_id, mode="honor", is_active=False):
def create_or_update_enrollment(cls, user, course_id, mode="honor", is_active=False):
"""
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
@@ -818,7 +818,7 @@ class CourseEnrollment(models.Model):
It is expected that this method is called from a method which has already
verified the user authentication and access.
"""
return cls.create_enrollment(user, course_id, mode, is_active=True)
return cls.create_or_update_enrollment(user, course_id, mode, is_active=True)
@classmethod
def enroll_by_email(cls, email, course_id, mode="honor", ignore_errors=True):

View File

@@ -443,7 +443,7 @@ class EnrollInCourseTest(TestCase):
# Creating an enrollment doesn't actually enroll a student
# (calling CourseEnrollment.enroll() would have)
enrollment = CourseEnrollment.create_enrollment(user, course_id)
enrollment = CourseEnrollment.create_or_update_enrollment(user, course_id)
self.assertFalse(CourseEnrollment.is_enrolled(user, course_id))
self.assert_no_events_were_emitted()

View File

@@ -467,7 +467,7 @@ class CertificateItem(OrderItem):
try:
course_enrollment = CourseEnrollment.objects.get(user=order.user, course_id=course_id)
except ObjectDoesNotExist:
course_enrollment = CourseEnrollment.create_enrollment(order.user, course_id, mode=mode)
course_enrollment = CourseEnrollment.create_or_update_enrollment(order.user, course_id, mode=mode)
# do some validation on the enrollment mode
valid_modes = CourseMode.modes_for_course_dict(course_id)