Commit 704e8836 by Will Daly

Course info page no longer creates enrollments.

The course info page was getting-or-creating
a course enrollment with is_active=0.  This commit
changes the operation to a "get" so that extra
enrollment records are not created.
parent 5d65f577
......@@ -9,6 +9,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_CLOSED_MODULESTORE
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from student.models import CourseEnrollment
from .helpers import LoginEnrollmentTestCase
......@@ -45,6 +46,20 @@ class CourseInfoTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
self.assertEqual(resp.status_code, 200)
self.assertNotIn("OOGIE BLOOGIE", resp.content)
def test_logged_in_not_enrolled(self):
self.setup_user()
url = reverse('info', args=[self.course.id.to_deprecated_string()])
self.client.get(url)
# Check whether the user has been enrolled in the course.
# There was a bug in which users would be automatically enrolled
# with is_active=False (same as if they enrolled and immediately unenrolled).
# This verifies that the user doesn't have *any* enrollment record.
enrollment_exists = CourseEnrollment.objects.filter(
user=self.user, course_id=self.course.id
).exists()
self.assertFalse(enrollment_exists)
class CourseInfoTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
"""
......
......@@ -665,7 +665,6 @@ def course_info(request, course_id):
Assumes the course_id is in a valid format.
"""
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
with modulestore().bulk_operations(course_key):
......@@ -1078,7 +1077,8 @@ def fetch_reverify_banner_info(request, course_key):
user = request.user
if not user.id:
return reverifications
enrollment = CourseEnrollment.get_or_create_enrollment(request.user, course_key)
enrollment = CourseEnrollment.get_enrollment(request.user, course_key)
if enrollment is not None:
course = modulestore().get_course(course_key)
info = single_course_reverification_info(user, course, enrollment)
if info:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment