From 1cfefe245749397d0093064fd9197771e40c6ba1 Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Wed, 6 Sep 2017 14:31:31 -0400 Subject: [PATCH 1/3] Modify the header to show the learner profile. Remove the profile from the user dropdown. LEARNER-2318 --- common/djangoapps/student/views.py | 1 + common/test/acceptance/pages/lms/dashboard.py | 9 +++- .../tests/lms/test_learner_profile.py | 3 +- .../courseware/tests/test_masquerade.py | 18 -------- lms/djangoapps/learner_dashboard/views.py | 2 + lms/djangoapps/student_account/views.py | 1 + .../bootstrap/navbar-authenticated.html | 17 ++++++-- .../navigation/navbar-authenticated.html | 17 ++++++-- lms/templates/user_dropdown.html | 3 -- .../learner_profile/views/learner_profile.py | 4 ++ themes/edx.org/lms/templates/header.html | 41 +++++++++++++++---- 11 files changed, 77 insertions(+), 39 deletions(-) diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 634f5ae82f..97de18b825 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -864,6 +864,7 @@ def dashboard(request): 'nav_hidden': True, 'inverted_programs': inverted_programs, 'show_program_listing': ProgramsApiConfig.is_enabled(), + 'show_dashboard_tabs': True, 'disable_courseware_js': True, 'display_course_modes_on_dashboard': enable_verified_certificates and display_course_modes_on_dashboard, 'display_sidebar_on_dashboard': display_sidebar_on_dashboard, diff --git a/common/test/acceptance/pages/lms/dashboard.py b/common/test/acceptance/pages/lms/dashboard.py index 24dbb07caf..a636638f0e 100644 --- a/common/test/acceptance/pages/lms/dashboard.py +++ b/common/test/acceptance/pages/lms/dashboard.py @@ -217,11 +217,18 @@ class DashboardPage(PageObject): """ return self.q(css='.user-dropdown-menu li a').text + @property + def tabs_link_text(self): + """ + Return the text of all the tabs on the dashboard. + """ + return self.q(css='.tab-nav-item a').text + def click_my_profile_link(self): """ Click on `Profile` link. """ - self.q(css='.user-dropdown-menu li a').nth(1).click() + self.q(css='.tab-nav-item a').nth(1).click() def click_account_settings_link(self): """ diff --git a/common/test/acceptance/tests/lms/test_learner_profile.py b/common/test/acceptance/tests/lms/test_learner_profile.py index f896cea2bb..f50fa56784 100644 --- a/common/test/acceptance/tests/lms/test_learner_profile.py +++ b/common/test/acceptance/tests/lms/test_learner_profile.py @@ -278,8 +278,7 @@ class OwnLearnerProfilePageTest(LearnerProfileTestMixin, AcceptanceTest): username, __ = self.log_in_as_unique_user() dashboard_page = DashboardPage(self.browser) dashboard_page.visit() - dashboard_page.click_username_dropdown() - self.assertIn('Profile', dashboard_page.username_dropdown_link_text) + self.assertIn('Profile', dashboard_page.tabs_link_text) dashboard_page.click_my_profile_link() my_profile_page = LearnerProfilePage(self.browser, username) my_profile_page.wait_for_page() diff --git a/lms/djangoapps/courseware/tests/test_masquerade.py b/lms/djangoapps/courseware/tests/test_masquerade.py index 072470b913..fbe1f9733c 100644 --- a/lms/djangoapps/courseware/tests/test_masquerade.py +++ b/lms/djangoapps/courseware/tests/test_masquerade.py @@ -154,20 +154,6 @@ class MasqueradeTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase): self.assertIn(self.problem_display_name, problem_html) self.assertEqual(show_answer_expected, "Show Answer" in problem_html) - def verify_real_user_profile_link(self): - """ - Verifies that the 'Profile' link in the navigation dropdown is pointing - to the real user. - """ - content = self.get_courseware_page().content - self.assertIn( - 'Profile'.format( - self.test_user.username - ), - content, - "Profile link should point to real user", - ) - def ensure_masquerade_as_group_member(self, partition_id, group_id): """ Installs a masquerade for the test_user and test course, to enable the @@ -376,9 +362,6 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi self.update_masquerade(role='student', user_name=self.student_user.username) self.assertEqual(self.get_progress_detail(), u'2/2') - # Verify that the user dropdown links have not changed - self.verify_real_user_profile_link() - # Temporarily override the student state. self.submit_answer('Correct', 'Incorrect') self.assertEqual(self.get_progress_detail(), u'1/2') @@ -461,7 +444,6 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi masquerade_progress = self.get_progress_page().content self.assertNotIn("1 of 2 possible points", masquerade_progress) self.assertIn("2 of 2 possible points", masquerade_progress) - self.verify_real_user_profile_link() @attr(shard=1) diff --git a/lms/djangoapps/learner_dashboard/views.py b/lms/djangoapps/learner_dashboard/views.py index 4dc2baf769..afab6be29c 100644 --- a/lms/djangoapps/learner_dashboard/views.py +++ b/lms/djangoapps/learner_dashboard/views.py @@ -35,6 +35,7 @@ def program_listing(request): 'programs': meter.engaged_programs, 'progress': meter.progress(), 'show_program_listing': programs_config.enabled, + 'show_dashboard_tabs': True, 'uses_pattern_library': True, } @@ -75,6 +76,7 @@ def program_details(request, program_uuid): context = { 'urls': urls, 'show_program_listing': programs_config.enabled, + 'show_dashboard_tabs': True, 'nav_hidden': True, 'disable_courseware_js': True, 'uses_pattern_library': True, diff --git a/lms/djangoapps/student_account/views.py b/lms/djangoapps/student_account/views.py index 206a565754..49b90e2b9d 100644 --- a/lms/djangoapps/student_account/views.py +++ b/lms/djangoapps/student_account/views.py @@ -555,6 +555,7 @@ def account_settings_context(request): 'user_preferences_api_url': reverse('preferences_api', kwargs={'username': user.username}), 'disable_courseware_js': True, 'show_program_listing': ProgramsApiConfig.is_enabled(), + 'show_dashboard_tabs': True, 'order_history': user_orders } diff --git a/lms/templates/navigation/bootstrap/navbar-authenticated.html b/lms/templates/navigation/bootstrap/navbar-authenticated.html index 6aa709ddc3..bde233fd52 100644 --- a/lms/templates/navigation/bootstrap/navbar-authenticated.html +++ b/lms/templates/navigation/bootstrap/navbar-authenticated.html @@ -33,15 +33,26 @@ from django.utils.translation import ugettext as _ % endif - % if show_program_listing: + % if show_dashboard_tabs: + % if show_program_listing: + + % endif + <% + self.real_user = getattr(user, 'real_user', user) + is_on_profile_page = data and data.get('profile_user_id') is not None + %> % endif diff --git a/lms/templates/navigation/navbar-authenticated.html b/lms/templates/navigation/navbar-authenticated.html index 20d236cb13..b62b36d7d3 100644 --- a/lms/templates/navigation/navbar-authenticated.html +++ b/lms/templates/navigation/navbar-authenticated.html @@ -16,15 +16,26 @@ from django.utils.translation import ugettext as _ ${_('Explore courses')} % endif - % if show_program_listing: + % if show_dashboard_tabs:
  • ${_("Courses")}
  • + % if show_program_listing: +
  • + + ${_("Programs")} + +
  • + % endif + <% + self.real_user = getattr(user, 'real_user', user) + is_on_profile_page = data and data.get('profile_user_id') is not None + %>
  • - - ${_("Programs")} + + ${_("Profile")}
  • % endif diff --git a/lms/templates/user_dropdown.html b/lms/templates/user_dropdown.html index 3ac2099b1e..80bd8bdea6 100644 --- a/lms/templates/user_dropdown.html +++ b/lms/templates/user_dropdown.html @@ -26,13 +26,11 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_ - % elif uses_pattern_library: @@ -54,7 +52,6 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_