ECOM-4334 Update learner dashboard

This commit is contained in:
Tasawer
2016-05-05 13:35:32 +05:00
parent 18cddf6e1e
commit caa5a0ac02
9 changed files with 102 additions and 47 deletions

View File

@@ -19,6 +19,7 @@ from django.test.utils import override_settings
from django.http import HttpRequest
from course_modes.models import CourseMode
from openedx.core.djangoapps.programs.tests.mixins import ProgramsApiConfigMixin
from openedx.core.djangoapps.user_api.accounts.api import activate_account, create_account
from openedx.core.djangoapps.user_api.accounts import EMAIL_MAX_LENGTH
from openedx.core.djangolib.js_utils import dump_js_escaped_json
@@ -442,7 +443,7 @@ class StudentAccountLoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMi
})
class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase):
class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase, ProgramsApiConfigMixin):
""" Tests for the account settings view. """
USERNAME = 'student'
@@ -456,6 +457,7 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase):
'year_of_birth',
'preferred_language',
]
view_path = reverse('account_settings')
@mock.patch("django.conf.settings.MESSAGE_STORAGE", 'django.contrib.messages.storage.cookie.CookieStorage')
def setUp(self):
@@ -502,12 +504,29 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase):
def test_view(self):
view_path = reverse('account_settings')
response = self.client.get(path=view_path)
response = self.client.get(path=self.view_path)
for attribute in self.FIELDS:
self.assertIn(attribute, response.content)
def test_header_with_programs_listing_enabled(self):
"""
Verify that tabs header will be shown while program listing is enabled.
"""
self.create_programs_config(program_listing_enabled=True)
response = self.client.get(path=self.view_path)
self.assertContains(response, '<li class="tab-nav-item">')
def test_header_with_programs_listing_disabled(self):
"""
Verify that nav header will be shown while program listing is disabled.
"""
self.create_programs_config(program_listing_enabled=False)
response = self.client.get(path=self.view_path)
self.assertContains(response, '<li class="item nav-global-01">')
@override_settings(SITE_NAME=settings.MICROSITE_LOGISTRATION_HOSTNAME)
class MicrositeLogistrationTests(TestCase):

View File

@@ -36,6 +36,7 @@ from third_party_auth import pipeline
from third_party_auth.decorators import xframe_allow_whitelisted
from util.bad_request_rate_limiter import BadRequestRateLimiter
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
from openedx.core.djangoapps.theming.helpers import is_request_in_themed_site, get_value as get_themed_value
from openedx.core.djangoapps.user_api.accounts.api import request_password_change
from openedx.core.djangoapps.user_api.errors import UserNotFound
@@ -394,6 +395,7 @@ def account_settings_context(request):
'user_accounts_api_url': reverse("accounts_api", kwargs={'username': user.username}),
'user_preferences_api_url': reverse('preferences_api', kwargs={'username': user.username}),
'disable_courseware_js': True,
'show_program_listing': ProgramsApiConfig.current().show_program_listing,
}
if third_party_auth.is_enabled():

View File

@@ -6,13 +6,13 @@ from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import RequestFactory
from util.testing import UrlResetMixin
from openedx.core.djangoapps.programs.tests.mixins import ProgramsApiConfigMixin
from student.tests.factories import UserFactory
from student_profile.views import learner_profile_context
from util.testing import UrlResetMixin
class LearnerProfileViewTest(UrlResetMixin, TestCase):
class LearnerProfileViewTest(UrlResetMixin, TestCase, ProgramsApiConfigMixin):
""" Tests for the student profile view. """
USERNAME = "username"
@@ -101,3 +101,23 @@ class LearnerProfileViewTest(UrlResetMixin, TestCase):
profile_path = reverse('learner_profile', kwargs={'username': "no_such_user"})
response = self.client.get(path=profile_path)
self.assertEqual(404, response.status_code)
def test_header_with_programs_listing_enabled(self):
"""
Verify that tabs header will be shown while program listing is enabled.
"""
self.create_programs_config(program_listing_enabled=True)
profile_path = reverse('learner_profile', kwargs={'username': self.USERNAME})
response = self.client.get(path=profile_path)
self.assertContains(response, '<li class="tab-nav-item">')
def test_header_with_programs_listing_disabled(self):
"""
Verify that nav header will be shown while program listing is disabled.
"""
self.create_programs_config(program_listing_enabled=False)
profile_path = reverse('learner_profile', kwargs={'username': self.USERNAME})
response = self.client.get(path=profile_path)
self.assertContains(response, '<li class="item nav-global-01">')

View File

@@ -12,6 +12,7 @@ from django.contrib.staticfiles.storage import staticfiles_storage
from badges.utils import badges_enabled
from edxmako.shortcuts import render_to_response, marketing_link
from microsite_configuration import microsite
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
from openedx.core.djangoapps.user_api.accounts.api import get_account_settings
from openedx.core.djangoapps.user_api.errors import UserNotFound, UserNotAuthorized
from openedx.core.djangoapps.user_api.preferences.api import get_user_preferences
@@ -95,6 +96,7 @@ def learner_profile_context(request, profile_username, user_is_staff):
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
},
'disable_courseware_js': True,
'show_program_listing': ProgramsApiConfig.current().show_program_listing,
}
if badges_enabled():

View File

@@ -49,13 +49,21 @@ site_status_msg = get_site_status_msg(course_id)
</%block>
<header id="global-navigation" class="header-global ${"slim" if course else ""}" >
<nav class="wrapper-header" aria-label="${_('Global')}">
<h1 class="logo">
<a href="${marketing_link('ROOT')}">
<%block name="navigation_logo">
<img src="${static.url(branding_api.get_logo_url())}" alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}"/>
</%block>
</a>
</h1>
<h1 class="logo">
<%block name="navigation_logo">
% if user.is_authenticated():
<a href="${reverse('dashboard')}">
<img src="${static.url(branding_api.get_logo_url())}" alt=${_("Your Dashboard")}/>
</a>
% else:
<a href="${marketing_link('ROOT')}">
<img src="${static.url(branding_api.get_logo_url())}"
alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}"/>
</a>
% endif
</%block>
</h1>
% if course:
<h2 class="course-header"><span class="provider">${course.display_org_with_default}:</span>

View File

@@ -28,8 +28,6 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_
</button>
<ul class="dropdown-menu list-divided is-hidden" id="${_("Usermenu")}" tabindex="-1">
<%block name="navigation_dropdown_menu_links" >
<li class="dropdown-item item has-block-link"><a href="${reverse('dashboard')}" class="action">${_("Dashboard")}</a></li>
<li class="dropdown-item item has-block-link"><a href="${reverse('learner_profile', kwargs={'username': user.username})}" class="action">${_("Profile")}</a></li>
<li class="dropdown-item item has-block-link"><a href="${reverse('account_settings')}" class="action">${_("Account")}</a></li>
</%block>
<li class="dropdown-item item has-block-link"><a href="${reverse('logout')}" role="menuitem" class="action">${_("Sign Out")}</a></li>
@@ -38,19 +36,19 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_
% else:
<ol class="user">
<li class="primary">
<a href="${reverse('dashboard')}" class="user-link">
<span class="sr">${_("Dashboard for:")}</span>
<a href="${reverse('learner_profile', kwargs={'username': user.username})}" class="user-link">
<span class="sr">${_("Profile for:")}</span>
<%
username = user.username
profile_image_url = get_profile_image_urls_for_user(user)['medium']
%>
<img class="user-image-frame" src="${profile_image_url}" alt="${_('Profile image for {username}').format(username=username)}">
<img class="user-image-frame" src="${profile_image_url}" alt="">
<div class="label-username">${username}</div>
</a>
</li>
<li class="primary">
<button class="dropdown" aria-haspopup="true" aria-expanded="false"><span class="sr">${_("More options dropdown")}</span><span class="fa fa-sort-desc" aria-hidden="true"></span></button>
<ul class="dropdown-menu" aria-label="More Options" role="menu">
<button class="dropdown" aria-haspopup="true" aria-expanded="false" title=${_("Account settings menu")}><span class="fa fa-sort-desc" aria-hidden="true"></span></button>
<ul class="dropdown-menu" aria-label=${_("Account settings")} role="menu">
${navigation_dropdown_menu_links()}
<li class="item"><a href="${reverse('logout')}" role="menuitem">${_("Sign Out")}</a></li>
</ul>