Add new info message to profile page.

This commit is contained in:
Diana Huang
2017-09-12 11:15:35 -04:00
committed by Andy Armstrong
parent 39cf0b44b5
commit cbfea6515d
13 changed files with 302 additions and 193 deletions

View File

@@ -11,3 +11,7 @@ WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='learner_profile')
# Waffle flag to show achievements on the learner profile.
# TODO: LEARNER-2443: 08/2017: Remove flag after rollout.
SHOW_ACHIEVEMENTS_FLAG = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'show_achievements')
# Waffle flag for showing a message about the new profile features.
# TODO: LEARNER-2554: 09/2017: Remove flag once message is no longer needed.
SHOW_PROFILE_MESSAGE = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'show_message')

View File

@@ -25,6 +25,11 @@
return function(options) {
var $learnerProfileElement = $('.wrapper-profile');
// TODO: LEARNER-2554: 09/2017: Remove this hiding logic when the message is removed.
$('.action-dismiss').click(function() {
$('.user-messages').hide();
});
var accountSettingsModel = new AccountSettingsModel(
_.extend(
options.account_settings_data,

View File

@@ -57,6 +57,13 @@
$('.wrapper-profile-section-container-one').removeClass('is-hidden');
$('.wrapper-profile-section-container-two').removeClass('is-hidden');
// Only show accomplishments if this is a full profile
if (this.showFullProfile()) {
$('.learner-achievements').removeClass('is-hidden');
} else {
$('.learner-achievements').addClass('is-hidden');
}
if (this.showFullProfile() && (this.options.accountSettingsModel.get('accomplishments_shared'))) {
tabs = [
{view: this.sectionTwoView, title: gettext('About Me'), url: 'about_me'},

View File

@@ -26,17 +26,17 @@ from openedx.core.djangolib.markup import HTML
<div class="wrapper-profile">
<div class="profile ${'profile-self' if own_profile else 'profile-other'}">
<div class="wrapper-profile-field-account-privacy"></div>
<div class="wrapper-profile-sections account-settings-container">
% if own_profile:
<div class="profile-header">
<div class="header">${_("My Profile")}</div>
<div class="subheader">
${_('Build out your profile to personalize your identity on {platform_name}.').format(
platform_name=platform_name,
)}
</div>
% if own_profile:
<div class="profile-header">
<div class="header">${_("My Profile")}</div>
<div class="subheader">
${_('Build out your profile to personalize your identity on {platform_name}.').format(
platform_name=platform_name,
)}
</div>
% endif
</div>
% endif
<div class="wrapper-profile-sections account-settings-container">
<div class="ui-loading-indicator">
<p><span class="spin"><span class="icon fa fa-refresh" aria-hidden="true"></span></span> <span class="copy">${_("Loading")}</span></p>
</div>

View File

@@ -8,6 +8,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.http import Http404
from django.shortcuts import render_to_response
from django.utils.translation import ugettext as _
from django.views.decorators.http import require_http_methods
from django_countries import countries
from edxmako.shortcuts import marketing_link
@@ -15,9 +16,11 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
from openedx.core.djangoapps.user_api.accounts.api import get_account_settings
from openedx.core.djangoapps.user_api.errors import UserNotAuthorized, UserNotFound
from openedx.core.djangoapps.user_api.preferences.api import get_user_preferences
from openedx.core.djangoapps.util.user_messages import PageLevelMessages
from openedx.core.djangolib.markup import HTML, Text
from student.models import User
from .. import SHOW_ACHIEVEMENTS_FLAG
from .. import SHOW_ACHIEVEMENTS_FLAG, SHOW_PROFILE_MESSAGE
from learner_achievements import LearnerAchievementsFragmentView
@@ -42,10 +45,33 @@ def learner_profile(request, username):
GET /account/profile
"""
try:
return render_to_response(
context = learner_profile_context(request, username, request.user.is_staff)
# TODO: LEARNER-2554: 09/2017: Remove message and cookie logic when we no longer want this message
message_viewed = False
if (context['own_profile'] and
SHOW_PROFILE_MESSAGE.is_enabled() and
request.COOKIES.get('profile-message-viewed', '') != 'True'):
message_text = Text(_(
'Welcome to the new learner profile page. Your full profile now displays more '
'information to other learners. You can instead choose to display a limited '
'profile. {learn_more_link_start}Learn more{learn_more_link_end}'
)).format(
learn_more_link_start=HTML(
'<a href="http://edx.readthedocs.io/projects/open-edx-learner-guide/en/'
'latest/SFD_dashboard_profile_SectionHead.html#adding-profile-information">'
),
learn_more_link_end=HTML('</a>')
)
PageLevelMessages.register_info_message(request, message_text, dismissable=True)
message_viewed = True
response = render_to_response(
'learner_profile/learner_profile.html',
learner_profile_context(request, username, request.user.is_staff)
context
)
if message_viewed:
response.set_cookie('profile-message-viewed', 'True')
return response
except (UserNotAuthorized, UserNotFound, ObjectDoesNotExist):
raise Http404