From e569e090c2be42c45267d3e16a14869d96457ebd Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Tue, 16 Sep 2014 11:00:47 -0400 Subject: [PATCH] redirect users from about page to info page when there is a marketing site (TNL-286) --- lms/djangoapps/courseware/tests/test_about.py | 13 +++++++++++++ lms/djangoapps/courseware/views.py | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/courseware/tests/test_about.py b/lms/djangoapps/courseware/tests/test_about.py index 44bb1e2b87..f4870a6b06 100644 --- a/lms/djangoapps/courseware/tests/test_about.py +++ b/lms/djangoapps/courseware/tests/test_about.py @@ -46,6 +46,19 @@ class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase): # Check that registration button is present self.assertIn(REG_STR, resp.content) + @patch.dict(settings.FEATURES, {'ENABLE_MKTG_SITE': True}) + def test_logged_in_marketing(self): + self.setup_user() + url = reverse('about_course', args=[self.course.id.to_deprecated_string()]) + resp = self.client.get(url) + # should be redirected + self.assertEqual(resp.status_code, 302) + # follow this time, and check we're redirected to the course info page + resp = self.client.get(url, follow=True) + target_url = resp.redirect_chain[-1][0] + info_url = reverse('info', args=[self.course.id.to_deprecated_string()]) + self.assertTrue(target_url.endswith(info_url)) + @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase): diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 5df386c957..35adef43d6 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -658,15 +658,15 @@ def course_about(request, course_id): Assumes the course_id is in a valid format. """ + course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) + course = get_course_with_access(request.user, 'see_exists', course_key) + if microsite.get_value( 'ENABLE_MKTG_SITE', settings.FEATURES.get('ENABLE_MKTG_SITE', False) ): - raise Http404 + return redirect(reverse('info', args=[course.id.to_deprecated_string()])) - course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) - - course = get_course_with_access(request.user, 'see_exists', course_key) registered = registered_for_course(course, request.user) staff_access = has_access(request.user, 'staff', course) studio_url = get_studio_url(course, 'settings/details')