Commit 4371f746 by AlasdairSwan

Merge pull request #8903 from edx/alasdair/header-light-ECOM-1661

ECOM-1661 removed nav links for logged out states
parents 37a0c19a 51deec38
......@@ -325,6 +325,22 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase):
self.assertEquals(course_modes, expected_modes)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@patch.dict(settings.FEATURES, {"IS_EDX_DOMAIN": True})
def test_hide_nav(self):
# Create the course modes
for mode in ["honor", "verified"]:
CourseModeFactory(mode_slug=mode, course_id=self.course.id)
# Load the track selection page
url = reverse('course_modes_choose', args=[unicode(self.course.id)])
response = self.client.get(url)
# Verify that the header navigation links are hidden for the edx.org version
self.assertNotContains(response, "How it Works")
self.assertNotContains(response, "Find courses")
self.assertNotContains(response, "Schools & Partners")
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class TrackSelectionEmbargoTest(UrlResetMixin, ModuleStoreTestCase):
......
......@@ -119,7 +119,8 @@ class ChooseModeView(View):
"course_num": course.display_number_with_default,
"chosen_price": chosen_price,
"error": error,
"responsive": True
"responsive": True,
"nav_hidden": True,
}
if "verified" in modes:
context["suggested_prices"] = [
......
......@@ -527,6 +527,19 @@ class DashboardTest(ModuleStoreTestCase):
response_3 = self.client.get(reverse('dashboard'))
self.assertEquals(response_3.status_code, 200)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@patch.dict(settings.FEATURES, {"IS_EDX_DOMAIN": True})
def test_dashboard_header_nav_has_find_courses(self):
self.client.login(username="jack", password="test")
response = self.client.get(reverse("dashboard"))
# "Find courses" is shown in the side panel
self.assertContains(response, "Find courses")
# But other links are hidden in the navigation
self.assertNotContains(response, "How it Works")
self.assertNotContains(response, "Schools & Partners")
class UserSettingsEventTestMixin(EventTestMixin):
"""
......
......@@ -698,6 +698,7 @@ def dashboard(request):
'order_history_list': order_history_list,
'courses_requirements_not_met': courses_requirements_not_met,
'ccx_membership_triplets': ccx_membership_triplets,
'nav_hidden': True,
}
return render_to_response('dashboard.html', context)
......
/**
* Adds rwd classes and click handlers.
*/
(function($) {
'use strict';
var rwd = (function() {
var _fn = {
header: 'header.global-new',
resultsUrl: 'course-search',
init: function() {
_fn.$header = $( _fn.header );
_fn.$footer = $( _fn.footer );
_fn.$navContainer = _fn.$header.find('.nav-container');
_fn.$globalNav = _fn.$header.find('.nav-global');
_fn.add.elements();
_fn.add.classes();
_fn.eventHandlers.init();
},
add: {
classes: function() {
// Add any RWD-specific classes
_fn.$header.addClass('rwd');
},
elements: function() {
_fn.add.burger();
_fn.add.registerLink();
},
burger: function() {
_fn.$navContainer.prepend([
'<a href="#" class="mobile-menu-button" aria-label="menu">',
'<i class="icon fa fa-bars" aria-hidden="true"></i>',
'</a>'
].join(''));
},
registerLink: function() {
var $register = _fn.$header.find('.cta-register'),
$li = {},
$a = {},
count = 0;
// Add if register link is shown
if ( $register.length > 0 ) {
count = _fn.$globalNav.find('li').length + 1;
// Create new li
$li = $('<li/>');
$li.addClass('desktop-hide nav-global-0' + count);
// Clone register link and remove classes
$a = $register.clone();
$a.removeClass();
// append to DOM
$a.appendTo( $li );
_fn.$globalNav.append( $li );
}
}
},
eventHandlers: {
init: function() {
_fn.eventHandlers.click();
},
click: function() {
// Toggle menu
_fn.$header.on( 'click', '.mobile-menu-button', _fn.toggleMenu );
}
},
toggleMenu: function( event ) {
event.preventDefault();
_fn.$globalNav.toggleClass('show');
}
};
return {
init: _fn.init
};
})();
rwd.init();
})(jQuery);
......@@ -49,20 +49,6 @@ class DashboardPage(PageObject):
return self.q(css='h3.course-title > a').map(_get_course_name).results
@property
def sidebar_menu_title(self):
"""
Return the title value for sidebar menu.
"""
return self.q(css='.user-info span.title').text[0]
@property
def sidebar_menu_description(self):
"""
Return the description text for sidebar menu.
"""
return self.q(css='.user-info span.copy').text[0]
def get_enrollment_mode(self, course_name):
"""Get the enrollment mode for a given course on the dashboard.
......
......@@ -268,12 +268,6 @@ class RegisterFromCombinedPageTest(UniqueCourseTest):
course_names = self.dashboard_page.wait_for_page().available_courses
self.assertIn(self.course_info["display_name"], course_names)
self.assertEqual("want to change your account settings?", self.dashboard_page.sidebar_menu_title.lower())
self.assertEqual(
"click the arrow next to your username above.",
self.dashboard_page.sidebar_menu_description.lower()
)
def test_register_failure(self):
# Navigate to the registration page
self.register_page.visit()
......
......@@ -406,3 +406,14 @@ class ReceiptViewTests(UserMixin, TestCase):
system_message = "A system error occurred while processing your payment"
self.assertRegexpMatches(response.content, user_message if is_user_message_expected else system_message)
self.assertNotRegexpMatches(response.content, user_message if not is_user_message_expected else system_message)
@mock.patch.dict(settings.FEATURES, {"IS_EDX_DOMAIN": True})
def test_hide_nav_header(self):
self._login()
post_data = {'decision': 'ACCEPT', 'reason_code': '200', 'signed_field_names': 'dummy'}
response = self.post_to_receipt_page(post_data)
# Verify that the header navigation links are hidden for the edx.org version
self.assertNotContains(response, "How it Works")
self.assertNotContains(response, "Find courses")
self.assertNotContains(response, "Schools & Partners")
......@@ -203,6 +203,7 @@ def checkout_receipt(request):
'error_text': error_text,
'for_help_text': for_help_text,
'payment_support_email': payment_support_email,
'nav_hidden': True,
}
return render_to_response('commerce/checkout_receipt.html', context)
......
......@@ -239,6 +239,17 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase):
)
self._assert_redirects_to_dashboard(response)
@patch.dict(settings.FEATURES, {"IS_EDX_DOMAIN": True})
def test_pay_and_verify_hides_header_nav(self):
course = self._create_course("verified")
self._enroll(course.id, "verified")
response = self._get_page('verify_student_start_flow', course.id)
# Verify that the header navigation links are hidden for the edx.org version
self.assertNotContains(response, "How it Works")
self.assertNotContains(response, "Find courses")
self.assertNotContains(response, "Schools & Partners")
def test_verify_now(self):
# We've already paid, and now we're trying to verify
course = self._create_course("verified")
......
......@@ -376,6 +376,7 @@ class PayAndVerifyView(View):
'already_verified': already_verified,
'verification_good_until': verification_good_until,
'capture_sound': staticfiles_storage.url("audio/camera_capture.wav"),
'nav_hidden': True,
}
return render_to_response("verify_student/pay_and_verify.html", context)
......
......@@ -1254,7 +1254,6 @@ dashboard_js = (
)
dashboard_search_js = ['js/search/dashboard/main.js']
discussion_js = sorted(rooted_glob(COMMON_ROOT / 'static', 'coffee/src/discussion/**/*.js'))
rwd_header_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/utils/rwd_header.js'))
staff_grading_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/staff_grading/**/*.js'))
open_ended_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/open_ended/**/*.js'))
notes_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/notes/**/*.js'))
......@@ -1267,7 +1266,6 @@ instructor_dash_js = (
# These are not courseware, so they do not need many of the courseware-specific
# JavaScript modules.
student_account_js = [
'js/utils/rwd_header.js',
'js/utils/edx.utils.validate.js',
'js/form.ext.js',
'js/my_courses_dropdown.js',
......@@ -1556,10 +1554,6 @@ PIPELINE_JS = {
'source_filenames': dashboard_search_js,
'output_filename': 'js/dashboard-search.js',
},
'rwd_header': {
'source_filenames': rwd_header_js,
'output_filename': 'js/rwd_header.js'
},
'student_account': {
'source_filenames': student_account_js,
'output_filename': 'js/student_account.js'
......
......@@ -352,6 +352,19 @@
}
}
%btn-pl-elevated-alt {
@extend %btn-pl-default-base;
box-shadow: 0 3px 0 0 $gray-l4;
border: 1px solid $gray-l4;
&:hover {
box-shadow: 0 3px 0 0 $action-primary-bg;
border: 1px solid $action-primary-bg;
background-color: lighten($action-primary-bg,20%);
color: $white;
}
}
// ====================
// application: canned actions
......
......@@ -15,14 +15,31 @@
@include clearfix();
padding: ($baseline*2) 0 0 0;
.wrapper-find-courses {
@include float(right);
@include margin-left(flex-gutter());
width: flex-grid(3);
margin-top: ($baseline*2);
border-top: 3px solid $blue;
padding: $baseline 0;
.copy {
@extend %t-copy-sub1;
}
.btn-find-courses {
@extend %btn-pl-elevated-alt;
}
}
.profile-sidebar {
background: transparent;
@include float(right);
margin-top: ($baseline*2);
@include margin-left(flex-gutter());
width: flex-grid(3);
box-shadow: 0 0 1px $shadow-l1;
border: 1px solid $border-color-2;
border-radius: 3px;
margin-top: ($baseline*2);
border-top: 3px solid $blue;
padding: $baseline 0;
.user-info {
@include clearfix();
......@@ -31,7 +48,7 @@
@include box-sizing(border-box);
@include clearfix();
margin: 0;
padding: $baseline;
padding: 0;
width: flex-grid(12);
li {
......@@ -59,7 +76,7 @@
}
span.title {
@extend %t-copy-sub1;
@extend %t-title6;
@extend %t-strong;
a {
......
......@@ -627,8 +627,8 @@ header.global-new {
a {
display:block;
padding: 3px 10px;
font-size: 18px;
line-height: 24px;
font-size: 14px;
line-height: 1.5;
font-weight: 600;
font-family: $header-sans-serif;
color: $courseware-navigation-color;
......@@ -715,7 +715,6 @@ header.global-new {
font-size: 14px;
&.nav-courseware-button {
width: 86px;
text-align: center;
margin-top: -3px;
}
......@@ -833,13 +832,6 @@ header.global-new {
.wrapper-header {
padding: 17px 0;
}
.nav-global,
.nav-courseware {
a {
font-size: 18px;
}
}
}
}
}
......
......@@ -15,7 +15,6 @@ from django.utils.translation import ugettext as _
</%block>
<%block name="js_extra">
<%static:js group='rwd_header'/>
<script src="${static.url('js/vendor/jquery.ajax-retry.js')}"></script>
<script src="${static.url('js/vendor/underscore-min.js')}"></script>
<script src="${static.url('js/vendor/underscore.string.min.js')}"></script>
......
......@@ -147,16 +147,19 @@ from django.core.urlresolvers import reverse
<section id="dashboard-search-results" class="search-results dashboard-search-results"></section>
% endif
<section class="profile-sidebar" id="profile-sidebar" role="region" aria-label="User info">
% if settings.FEATURES.get('IS_EDX_DOMAIN'):
<div class="wrapper-find-courses">
<p class="copy">Check out our recently launched courses and what's new in your favorite subjects</p>
<p><a class="btn-find-courses" href="${marketing_link('COURSES')}">${_("Find New Courses")}</a></p>
</div>
% endif
<section class="profile-sidebar" id="profile-sidebar" role="region" aria-label="Account Status Info">
<header class="profile">
<h2 class="username-header"><span class="sr">${_("Username")}: </span></h2>
<h2 class="account-status-title sr">${_("Account Status Info")}: </h2>
</header>
<section class="user-info">
<ul>
<li class="heads-up">
<span class="title">${_("Want to change your account settings?")}</span>
<span class="copy">${_("Click the arrow next to your username above.")}</span>
</li>
% if len(order_history_list):
<li class="order-history">
......
......@@ -53,6 +53,7 @@ site_status_msg = get_site_status_msg(course_id)
% if user.is_authenticated():
% if not course or disable_courseware_header:
% if not nav_hidden:
<nav aria-label="Main" class="nav-main">
<ul class="left nav-global authenticated">
<%block name="navigation_global_links_authenticated">
......@@ -68,6 +69,7 @@ site_status_msg = get_site_status_msg(course_id)
</%block>
</ul>
</nav>
% endif
% endif
<ul class="user">
......@@ -101,44 +103,28 @@ site_status_msg = get_site_status_msg(course_id)
% endif
% else:
<nav aria-label="Main" class="nav-main">
<ul class="left nav-global">
<%block name="navigation_global_links">
<li class="nav-global-01">
<a href="${marketing_link('HOW_IT_WORKS')}">${_("How it Works")}</a>
</li>
<li class="nav-global-02">
<a href="${marketing_link('COURSES')}">${_("Find Courses")}</a>
</li>
<li class="nav-global-03">
<a href="${marketing_link('SCHOOLS')}">${_("Schools & Partners")}</a>
</li>
</%block>
</ul>
</nav>
<nav aria-label="Account" class="nav-account-management">
<div class="right nav-courseware">
<div class="nav-courseware-01">
% if not settings.FEATURES['DISABLE_LOGIN_BUTTON']:
% if course and settings.FEATURES.get('RESTRICT_ENROLL_BY_REG_METHOD') and course.enrollment_domain:
<a class="cta cta-login" href="${reverse('course-specific-login', args=[course.id.to_deprecated_string()])}${login_query()}">${_("Sign in")}</a>
% else:
<a class="cta cta-login" href="/login${login_query()}">${_("Sign in")}</a>
% endif
% endif
</div>
% if not settings.FEATURES['DISABLE_LOGIN_BUTTON']:
% if course and settings.FEATURES.get('RESTRICT_ENROLL_BY_REG_METHOD') and course.enrollment_domain:
<div class="nav-courseware-01">
<a class="cta cta-register" href="${reverse('course-specific-register', args=[course.id.to_deprecated_string()])}">${_("Register")}</a>
<div class="nav-courseware-02">
<a class="cta cta-register nav-courseware-button" href="${reverse('course-specific-register', args=[course.id.to_deprecated_string()])}">${_("Register")}</a>
</div>
% else:
<div class="nav-courseware-01">
<a class="cta cta-register" href="/register">${_("Register")}</a>
<div class="nav-courseware-02">
<a class="cta cta-register nav-courseware-button" href="/register">${_("Register")}</a>
</div>
% endif
% endif
<div class="nav-courseware-02">
% if not settings.FEATURES['DISABLE_LOGIN_BUTTON']:
% if course and settings.FEATURES.get('RESTRICT_ENROLL_BY_REG_METHOD') and course.enrollment_domain:
<a class="cta cta-login nav-courseware-button" href="${reverse('course-specific-login', args=[course.id.to_deprecated_string()])}${login_query()}">${_("Sign in")}</a>
% else:
<a class="cta cta-login nav-courseware-button" href="/login${login_query()}">${_("Sign in")}</a>
% endif
% endif
</div>
</div>
</nav>
% endif
......
......@@ -18,7 +18,6 @@ from django.utils.translation import ugettext as _
% endfor
</%block>
<%block name="js_extra">
<%static:js group='rwd_header'/>
<script src="${static.url('js/vendor/underscore-min.js')}"></script>
<script src="${static.url('js/vendor/underscore.string.min.js')}"></script>
<script src="${static.url('js/vendor/backbone-min.js')}"></script>
......
......@@ -35,7 +35,6 @@ from verify_student.views import PayAndVerifyView
% endfor
</%block>
<%block name="js_extra">
<%static:js group='rwd_header'/>
<script src="${static.url('js/vendor/underscore-min.js')}"></script>
<script src="${static.url('js/vendor/underscore.string.min.js')}"></script>
<script src="${static.url('js/vendor/backbone-min.js')}"></script>
......
......@@ -16,7 +16,6 @@ from django.utils.translation import ugettext as _
% endfor
</%block>
<%block name="js_extra">
<%static:js group='rwd_header'/>
<script src="${static.url('js/vendor/underscore-min.js')}"></script>
<script src="${static.url('js/vendor/underscore.string.min.js')}"></script>
<script src="${static.url('js/vendor/backbone-min.js')}"></script>
......
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