DISCO-1522: check if enrolled before congrats message

This helps out the Verified Only case where the user
is not first enrolled as an audit learner.
This commit is contained in:
Dillon Dumesnil
2019-12-18 16:40:57 +00:00
parent 1fe28deed9
commit 7165eeff44
2 changed files with 28 additions and 3 deletions

View File

@@ -199,6 +199,29 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
else:
self.assertNotContains(response, "Credit")
@httpretty.activate
@ddt.data(True, False)
def test_congrats_on_enrollment_message(self, create_enrollment):
# Create the course mode
CourseModeFactory.create(mode_slug='verified', course_id=self.course.id)
if create_enrollment:
CourseEnrollmentFactory(
is_active=True,
course_id=self.course.id,
user=self.user
)
# Check whether congratulations message is shown on the page
# This should *only* be shown when an enrollment exists
url = reverse('course_modes_choose', args=[six.text_type(self.course.id)])
response = self.client.get(url)
if create_enrollment:
self.assertContains(response, "Congratulations! You are now enrolled in")
else:
self.assertNotContains(response, "Congratulations! You are now enrolled in")
@ddt.data('professional', 'no-id-professional')
def test_professional_enrollment(self, mode):
# The only course mode is professional ed

View File

@@ -191,9 +191,11 @@ class ChooseModeView(View):
)
)
title_content = _("Congratulations! You are now enrolled in {course_name}").format(
course_name=course.display_name_with_default
)
title_content = ''
if enrollment_mode:
title_content = _("Congratulations! You are now enrolled in {course_name}").format(
course_name=course.display_name_with_default
)
context["title_content"] = title_content