From 944f51a60bb22b193610ed198eb5aabdcb6c31e7 Mon Sep 17 00:00:00 2001 From: Brian Talbot Date: Wed, 5 Aug 2015 13:13:33 -0400 Subject: [PATCH] LMS: removing old and not needed edx.org MKTG iframe assets * removing templates/styling * removing test logic and URLs --- lms/djangoapps/courseware/tests/test_views.py | 133 ----------------- lms/djangoapps/courseware/views.py | 91 ------------ lms/static/sass/_shame.scss | 72 ---------- .../courseware/mktg_coming_soon.html | 29 ---- .../courseware/mktg_course_about.html | 135 ------------------ lms/templates/mktg_iframe.html | 41 ------ lms/urls.py | 6 - 7 files changed, 507 deletions(-) delete mode 100644 lms/templates/courseware/mktg_coming_soon.html delete mode 100644 lms/templates/courseware/mktg_course_about.html delete mode 100644 lms/templates/mktg_iframe.html diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index ba844b8e88..cd4f67d839 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -382,112 +382,6 @@ class ViewsTestCase(ModuleStoreTestCase): # generate/store a real password. self.assertEqual(chat_settings['password'], "johndoe@%s" % domain) - @patch.dict(settings.FEATURES, {'ENABLE_MKTG_EMAIL_OPT_IN': True}) - def test_course_mktg_about_coming_soon(self): - # We should not be able to find this course - url = reverse('mktg_about_course', kwargs={'course_id': 'no/course/here'}) - response = self.client.get(url, {'org': self.org}) - self.assertIn('Coming Soon', response.content) - - # Verify that the checkbox is not displayed - self._email_opt_in_checkbox(response) - - @patch.dict(settings.FEATURES, {'ENABLE_MKTG_EMAIL_OPT_IN': True}) - @ddt.data( - # One organization name - (u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ", u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ"), - # Two organization names - (",".join([u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ"] * 2), u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ" + " and " + u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ"), - # Three organization names - (",".join([u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ"] * 3), u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ" + ", " + u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ" + ", " + "and " + u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ") - ) - @ddt.unpack - def test_course_mktg_register(self, org, org_name_string): - response = self._load_mktg_about(org=org) - self.assertIn('Enroll in', response.content) - self.assertNotIn('and choose your student track', response.content) - - # Verify that the checkbox is displayed - self._email_opt_in_checkbox(response, org_name_string) - - @patch.dict(settings.FEATURES, {'ENABLE_MKTG_EMAIL_OPT_IN': True}) - @ddt.data( - # One organization name - (u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ", u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ"), - # Two organization names - (",".join([u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ"] * 2), u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ" + " and " + u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ"), - # Three organization names - (",".join([u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ"] * 3), u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ" + ", " + u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ" + ", " + "and " + u"ꜱᴛᴀʀᴋ ɪɴᴅᴜꜱᴛʀɪᴇꜱ") - ) - @ddt.unpack - def test_course_mktg_register_multiple_modes(self, org, org_name_string): - CourseMode.objects.get_or_create( - mode_slug='honor', - mode_display_name='Honor Code Certificate', - course_id=self.course_key - ) - CourseMode.objects.get_or_create( - mode_slug='verified', - mode_display_name='Verified Certificate', - course_id=self.course_key - ) - - response = self._load_mktg_about(org=org) - self.assertIn('Enroll in', response.content) - self.assertIn('and choose your student track', response.content) - - # Verify that the checkbox is displayed - self._email_opt_in_checkbox(response, org_name_string) - - # clean up course modes - CourseMode.objects.all().delete() - - @patch.dict(settings.FEATURES, {'ENABLE_MKTG_EMAIL_OPT_IN': True}) - def test_course_mktg_no_organization_name(self): - # Don't pass an organization name as a GET parameter, even though the email - # opt-in feature is enabled. - response = response = self._load_mktg_about() - - # Verify that the checkbox is not displayed - self._email_opt_in_checkbox(response) - - @patch.dict(settings.FEATURES, {'ENABLE_MKTG_EMAIL_OPT_IN': False}) - def test_course_mktg_opt_in_disabled(self): - # Pass an organization name as a GET parameter, even though the email - # opt-in feature is disabled. - response = self._load_mktg_about(org=self.org) - - # Verify that the checkbox is not displayed - self._email_opt_in_checkbox(response) - - @patch.dict(settings.FEATURES, {'ENABLE_MKTG_EMAIL_OPT_IN': True}) - def test_course_mktg_organization_html(self): - response = self._load_mktg_about(org=self.org_html) - - # Verify that the checkbox is displayed with the organization name - # in the label escaped as expected. - self._email_opt_in_checkbox(response, cgi.escape(self.org_html)) - - @patch.dict(settings.FEATURES, { - 'IS_EDX_DOMAIN': True, - 'ENABLE_MKTG_EMAIL_OPT_IN': True - }) - def test_mktg_about_language_edx_domain(self): - # Since we're in an edx-controlled domain, and our marketing site - # supports only English, override the language setting - # and use English. - response = self._load_mktg_about(language='eo', org=self.org_html) - self.assertContains(response, "Enroll in") - self.assertContains(response, "and learn about its other programs") - - @patch.dict(settings.FEATURES, {'IS_EDX_DOMAIN': False}) - def test_mktg_about_language_openedx(self): - # If we're in an OpenEdX installation, - # may want to support languages other than English, - # so respect the language code. - response = self._load_mktg_about(language='eo') - self.assertContains(response, u"Énröll ïn".encode('utf-8')) - def test_submission_history_accepts_valid_ids(self): # log into a staff account admin = AdminFactory() @@ -572,33 +466,6 @@ class ViewsTestCase(ModuleStoreTestCase): self.assertIn("Score: 3.0 / 3.0", response_content) self.assertIn('#4', response_content) - def _load_mktg_about(self, language=None, org=None): - """Retrieve the marketing about button (iframed into the marketing site) - and return the HTTP response. - - Keyword Args: - language (string): If provided, send this in the 'Accept-Language' HTTP header. - org (string): If provided, send the string as a GET parameter. - - Returns: - Response - - """ - # Log in as an administrator to guarantee that we can access the button - admin = AdminFactory() - self.client.login(username=admin.username, password='test') - - # If provided, set the language header - headers = {} - if language is not None: - headers['HTTP_ACCEPT_LANGUAGE'] = language - - url = reverse('mktg_about_course', kwargs={'course_id': unicode(self.course_key)}) - if org: - return self.client.get(url, {'org': org}, **headers) - else: - return self.client.get(url, **headers) - def _email_opt_in_checkbox(self, response, org_name_string=None): """Check if the email opt-in checkbox appears in the response content.""" checkbox_html = '' diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index ab50ece15f..d1d595317e 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -923,97 +923,6 @@ def course_about(request, course_id): }) -@ensure_csrf_cookie -@cache_if_anonymous('org') -@ensure_valid_course_key -def mktg_course_about(request, course_id): - """This is the button that gets put into an iframe on the Drupal site.""" - course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) - - try: - permission_name = microsite.get_value( - 'COURSE_ABOUT_VISIBILITY_PERMISSION', - settings.COURSE_ABOUT_VISIBILITY_PERMISSION - ) - course = get_course_with_access(request.user, permission_name, course_key) - except (ValueError, Http404): - # If a course does not exist yet, display a "Coming Soon" button - return render_to_response( - 'courseware/mktg_coming_soon.html', {'course_id': course_key.to_deprecated_string()} - ) - - registered = registered_for_course(course, request.user) - - if has_access(request.user, 'load', course): - course_target = reverse('info', args=[course.id.to_deprecated_string()]) - else: - course_target = reverse('about_course', args=[course.id.to_deprecated_string()]) - - allow_registration = bool(has_access(request.user, 'enroll', course)) - - show_courseware_link = bool(has_access(request.user, 'load', course) or - settings.FEATURES.get('ENABLE_LMS_MIGRATION')) - course_modes = CourseMode.modes_for_course_dict(course.id) - - context = { - 'course': course, - 'registered': registered, - 'allow_registration': allow_registration, - 'course_target': course_target, - 'show_courseware_link': show_courseware_link, - 'course_modes': course_modes, - } - - # The edx.org marketing site currently displays only in English. - # To avoid displaying a different language in the register / access button, - # we force the language to English. - # However, OpenEdX installations with a different marketing front-end - # may want to respect the language specified by the user or the site settings. - force_english = settings.FEATURES.get('IS_EDX_DOMAIN', False) - if force_english: - translation.activate('en-us') - - if settings.FEATURES.get('ENABLE_MKTG_EMAIL_OPT_IN'): - # Drupal will pass organization names using a GET parameter, as follows: - # ?org=Harvard - # ?org=Harvard,MIT - # If no full names are provided, the marketing iframe won't show the - # email opt-in checkbox. - org = request.GET.get('org') - if org: - org_list = org.split(',') - # HTML-escape the provided organization names - org_list = [cgi.escape(org) for org in org_list] - if len(org_list) > 1: - if len(org_list) > 2: - # Translators: The join of three or more institution names (e.g., Harvard, MIT, and Dartmouth). - org_name_string = _("{first_institutions}, and {last_institution}").format( - first_institutions=u", ".join(org_list[:-1]), - last_institution=org_list[-1] - ) - else: - # Translators: The join of two institution names (e.g., Harvard and MIT). - org_name_string = _("{first_institution} and {second_institution}").format( - first_institution=org_list[0], - second_institution=org_list[1] - ) - else: - org_name_string = org_list[0] - - context['checkbox_label'] = ungettext( - "I would like to receive email from {institution_series} and learn about its other programs.", - "I would like to receive email from {institution_series} and learn about their other programs.", - len(org_list) - ).format(institution_series=org_name_string) - - try: - return render_to_response('courseware/mktg_course_about.html', context) - finally: - # Just to be safe, reset the language if we forced it to be English. - if force_english: - translation.deactivate() - - @login_required @cache_control(no_cache=True, no_store=True, must_revalidate=True) @transaction.commit_manually diff --git a/lms/static/sass/_shame.scss b/lms/static/sass/_shame.scss index bd6e63be4d..c2e3770643 100644 --- a/lms/static/sass/_shame.scss +++ b/lms/static/sass/_shame.scss @@ -132,80 +132,8 @@ } - - // ==================== -// edx.org marketing site - registration iframe band-aid (poor form enough to isolate out) -.view-iframe, .view-iframe-content { - background: transparent !important; - overflow: hidden; -} - -.view-partial-mktgregister { - background: transparent !important; - - // dimensions needed for course about page on marketing site - .wrapper-view { - overflow: hidden; - } - - // nav list - .list-actions { - list-style: none; - margin: 0; - padding: 0; - - .item { - margin: 0; - } - } - - .action { - font-size: 16px; - font-weight: 500; - - // register or access courseware - &.action-register, &.access-courseware { - @extend %m-btn-primary; - display: block; - - .track { - @include transition(all $tmg-f2 ease-in-out); - color: $white; - display: block; - font-size: 13px; - line-height: 2em; - opacity: 0.6; - } - - &:hover .track, &:focus .track { - opacity: 1.0; - } - - &.has-option-verified { - padding-top: 12px !important; - } - } - - // already registered but course not started or registration is closed - &.is-registered, &.registration-closed { - @extend %m-btn-secondary; - pointer-events: none !important; - display: block; - } - - // coming soon - &.coming-soon { - @extend %m-btn-secondary; - pointer-events: none !important; - outline: none; - display: block; - } - } -} - -// ==================== // Verification fixes .verification-process { diff --git a/lms/templates/courseware/mktg_coming_soon.html b/lms/templates/courseware/mktg_coming_soon.html deleted file mode 100644 index 6781eb9386..0000000000 --- a/lms/templates/courseware/mktg_coming_soon.html +++ /dev/null @@ -1,29 +0,0 @@ -<%namespace name='static' file='../static_content.html'/> -<%inherit file="../mktg_iframe.html" /> -<%! -from django.utils.translation import ugettext as _ -from django.core.urlresolvers import reverse -from courseware.courses import course_image_url, get_course_about_section -%> - -<%block name="pagetitle">${_("About {course_id}").format(course_id=course_id) | h} - -<%block name="bodyclass">view-iframe-content view-partial-mktgregister - - -<%block name="headextra"> - <%include file="../google_analytics.html" /> - - -<%block name="content"> - - - - - - - diff --git a/lms/templates/courseware/mktg_course_about.html b/lms/templates/courseware/mktg_course_about.html deleted file mode 100644 index d0eb011cd0..0000000000 --- a/lms/templates/courseware/mktg_course_about.html +++ /dev/null @@ -1,135 +0,0 @@ -<%namespace name='static' file='../static_content.html'/> -<%inherit file="../mktg_iframe.html" /> -<%! -from django.utils.translation import ugettext as _ -from django.core.urlresolvers import reverse -from courseware.courses import course_image_url, get_course_about_section -%> - -<%block name="pagetitle">${_("About {course_number}").format(course_number=course.display_number_with_default) | h} - -<%block name="bodyclass">view-iframe-content view-partial-mktgregister - -<%block name="js_extra"> - - - -<%block name="content"> - - - - -%if not registered: -
-
-
- ${_("Enroll")} - - - - -
-
- -
-
-
-%endif - diff --git a/lms/templates/mktg_iframe.html b/lms/templates/mktg_iframe.html deleted file mode 100644 index a1c1bd8767..0000000000 --- a/lms/templates/mktg_iframe.html +++ /dev/null @@ -1,41 +0,0 @@ -<%namespace name='static' file='static_content.html'/> - - - - - <%block name="title"> - - - - - - <%static:css group='style-vendor'/> - <%static:css group='style-main'/> - <%static:js group='base_vendor'/> - - <%block name="headextra"/> - - <%include file="widgets/optimizely.html" /> - - - - - - - - - - -
- - <%block name="content"> -
- - <%static:js group='application'/> - <%block name="js_extra"> - - diff --git a/lms/urls.py b/lms/urls.py index 7c16f6b1cc..4bd1ad9266 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -298,12 +298,6 @@ if settings.COURSEWARE_ENABLED: #About the course url(r'^courses/{}/about$'.format(settings.COURSE_ID_PATTERN), 'courseware.views.course_about', name="about_course"), - #View for mktg site (kept for backwards compatibility TODO - remove before merge to master) - url(r'^courses/{}/mktg-about$'.format(settings.COURSE_ID_PATTERN), - 'courseware.views.mktg_course_about', name="mktg_about_course"), - #View for mktg site - url(r'^mktg/{}/?$'.format(settings.COURSE_ID_PATTERN), - 'courseware.views.mktg_course_about', name="mktg_about_course"), #Inside the course url(r'^courses/{}/$'.format(settings.COURSE_ID_PATTERN),