Merge pull request #9207 from edx/talbs/remove-mktg-iframe
Clean Up: Remove edx.org Specific MKTG Iframe Assets
This commit is contained in:
@@ -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 = '<input id="email-opt-in" type="checkbox" name="opt-in" class="email-opt-in" value="true" checked>'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
|
||||
<%block name="bodyclass">view-iframe-content view-partial-mktgregister</%block>
|
||||
|
||||
|
||||
<%block name="headextra">
|
||||
<%include file="../google_analytics.html" />
|
||||
</%block>
|
||||
|
||||
<%block name="content">
|
||||
|
||||
<script src="${static.url('js/course_info.js')}"></script>
|
||||
|
||||
|
||||
<ul class="list-actions register">
|
||||
<li class="item">
|
||||
<a class="action coming-soon" href="">${_("Coming Soon")}</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</%block>
|
||||
@@ -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>
|
||||
|
||||
<%block name="bodyclass">view-iframe-content view-partial-mktgregister</%block>
|
||||
|
||||
<%block name="js_extra">
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
$(".register").click(function(event) {
|
||||
var el = $("input[name='email_opt_in']"),
|
||||
emailOptIn,
|
||||
currentHref;
|
||||
|
||||
// Check if the email opt-in checkbox is missing
|
||||
if ( $("#email-opt-in").length == 0 ) {
|
||||
// Remove the corresponding hidden form element
|
||||
el.remove();
|
||||
} else {
|
||||
// Check if the email opt-in checkbox is not checked
|
||||
if ( !$("#email-opt-in").prop("checked") ) {
|
||||
// Set the value of the corresponding hidden form element
|
||||
el.val("false");
|
||||
}
|
||||
|
||||
emailOptIn = el.val();
|
||||
currentHref = $("a.register").attr("href");
|
||||
if (currentHref) {
|
||||
$("a.register").attr("href", currentHref + "&email_opt_in=" + emailOptIn);
|
||||
}
|
||||
}
|
||||
|
||||
$("#class_enroll_form").submit();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$('#class_enroll_form').on('ajax:complete', function(event, xhr) {
|
||||
var emailOptIn = '';
|
||||
|
||||
if(xhr.status == 200) {
|
||||
if (xhr.responseText != "") {
|
||||
window.top.location.href = xhr.responseText;
|
||||
}
|
||||
else {
|
||||
window.top.location.href = "${reverse('dashboard')}";
|
||||
}
|
||||
} else if (xhr.status == 403) {
|
||||
// Check if the email opt-in checkbox is present
|
||||
if ( $("#email-opt-in").length != 0 ) {
|
||||
emailOptIn = '&email_opt_in=' + $("input[name='email_opt_in']").val();
|
||||
}
|
||||
|
||||
## Ugh.
|
||||
window.top.location.href = $("a.register").attr("href") || "${reverse('register_user')}?course_id=${course.id | u}&enrollment_action=enroll&email_opt_in=" + emailOptIn;
|
||||
} else {
|
||||
$('#register_error').html(
|
||||
(xhr.responseText ? xhr.responseText : "${_("An error occurred. Please try again later.")}")
|
||||
).css("display", "block");
|
||||
}
|
||||
});
|
||||
})(this)
|
||||
</script>
|
||||
</%block>
|
||||
|
||||
<%block name="content">
|
||||
<script src="${static.url('js/course_info.js')}"></script>
|
||||
|
||||
<ul class="list-actions">
|
||||
<li class="item">
|
||||
%if user.is_authenticated() and registered:
|
||||
%if show_courseware_link:
|
||||
<a class="action access-courseware" href="${course_target}" target="_top">${_("Access Courseware")}</a>
|
||||
%else:
|
||||
<div class="action is-registered">${_("You Are Enrolled")}</div>
|
||||
%endif
|
||||
%elif allow_registration:
|
||||
<a class="action action-register register ${'has-option-verified' if len(course_modes) > 1 else ''}"
|
||||
%if not user.is_authenticated():
|
||||
href="${reverse('register_user')}?course_id=${course.id | u}&enrollment_action=enroll"
|
||||
%endif
|
||||
>${_("Enroll in")} <strong>${course.display_number_with_default | h}</strong>
|
||||
%if len(course_modes) > 1:
|
||||
<span class="track">
|
||||
## Translators: This is the second line on a button users can click. The first line is "Enroll in COURSE_NAME"
|
||||
## The "choose your student track" means users can select between taking the course as an auditor, as a verified student, etc
|
||||
${_("and choose your student track")}
|
||||
</span>
|
||||
%elif "professional" in course_modes:
|
||||
<span class="track">
|
||||
## Translators: This is the second line on a button users can click. The first line is "Enroll in COURSE_NAME"
|
||||
## 'Verification' here refers to verifying one's identity in order to receive a verified certificate.
|
||||
${_("and proceed to verification")}
|
||||
</span>
|
||||
%endif
|
||||
</a>
|
||||
|
||||
% if settings.FEATURES.get('ENABLE_MKTG_EMAIL_OPT_IN'):
|
||||
## We only display the email opt-in checkbox if we've been given one or more organization names.
|
||||
% if checkbox_label:
|
||||
<p class="form-field">
|
||||
<input id="email-opt-in" type="checkbox" name="opt-in" class="email-opt-in" value="true" checked>
|
||||
<label for="email-opt-in" class="register-emails">${checkbox_label}</label>
|
||||
</p>
|
||||
% endif
|
||||
% endif
|
||||
|
||||
%else:
|
||||
<div class="action registration-closed is-disabled" aria-disabled="true" >${_("Enrollment Is Closed")}</div>
|
||||
%endif
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
%if not registered:
|
||||
<div style="display: none;">
|
||||
<form id="class_enroll_form" method="post" data-remote="true" action="${reverse('change_enrollment')}">
|
||||
<fieldset class="enroll_fieldset">
|
||||
<legend class="sr">${_("Enroll")}</legend>
|
||||
<input name="course_id" type="hidden" value="${course.id | h}">
|
||||
<input name="enrollment_action" type="hidden" value="enroll">
|
||||
<input name="email_opt_in" type="hidden" value="true">
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="${ csrf_token }">
|
||||
</fieldset>
|
||||
<div class="submit">
|
||||
<input name="enroll" type="submit" value="${_('enroll')}">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
%endif
|
||||
</%block>
|
||||
File diff suppressed because one or more lines are too long
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user