From 73af5d017ec296f58f6a67c28b1665a0d4fc3bfe Mon Sep 17 00:00:00 2001 From: Julia Hansbrough Date: Fri, 8 Nov 2013 19:01:51 +0000 Subject: [PATCH] Changed create_enrollment to create_or_update_enrollment --- common/djangoapps/student/models.py | 4 ++-- common/djangoapps/student/tests/tests.py | 2 +- lms/djangoapps/shoppingcart/models.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 6387f282e1..b648adf51d 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -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): diff --git a/common/djangoapps/student/tests/tests.py b/common/djangoapps/student/tests/tests.py index 634996fd55..2239259a1d 100644 --- a/common/djangoapps/student/tests/tests.py +++ b/common/djangoapps/student/tests/tests.py @@ -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() diff --git a/lms/djangoapps/shoppingcart/models.py b/lms/djangoapps/shoppingcart/models.py index 03be80861a..8a91a77286 100644 --- a/lms/djangoapps/shoppingcart/models.py +++ b/lms/djangoapps/shoppingcart/models.py @@ -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)