diff --git a/common/djangoapps/util/views.py b/common/djangoapps/util/views.py index cdf5f860a3..e8c039e7b0 100644 --- a/common/djangoapps/util/views.py +++ b/common/djangoapps/util/views.py @@ -455,7 +455,7 @@ def submit_feedback(request): context = get_feedback_form_context(request) #Update the tag info with 'enterprise_learner' if the user belongs to an enterprise customer. - enterprise_learner_data = enterprise_api.get_enterprise_learner_data(site=request.site, user=request.user) + enterprise_learner_data = enterprise_api.get_enterprise_learner_data(request.user) if enterprise_learner_data: context["tags"]["learner_type"] = "enterprise_learner" diff --git a/lms/djangoapps/course_wiki/tests/tests.py b/lms/djangoapps/course_wiki/tests/tests.py index 8328880c83..a18f051a45 100644 --- a/lms/djangoapps/course_wiki/tests/tests.py +++ b/lms/djangoapps/course_wiki/tests/tests.py @@ -205,10 +205,14 @@ class WikiRedirectTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCas self.assertEqual(resp.status_code, 200) @patch.dict("django.conf.settings.FEATURES", {'ALLOW_WIKI_ROOT_ACCESS': True}) - def test_consent_required(self): + @patch('openedx.features.enterprise_support.api.enterprise_customer_for_request') + def test_consent_required(self, mock_enterprise_customer_for_request): """ Test that enterprise data sharing consent is required when enabled for the various courseware views. """ + # ENT-924: Temporary solution to replace sensitive SSO usernames. + mock_enterprise_customer_for_request.return_value = None + # Public wikis can be accessed by non-enrolled users, and so direct access is not gated by the consent page course = CourseFactory.create() course.allow_public_wiki_access = False diff --git a/lms/djangoapps/courseware/tests/test_course_info.py b/lms/djangoapps/courseware/tests/test_course_info.py index 168276894b..04ec1bf688 100644 --- a/lms/djangoapps/courseware/tests/test_course_info.py +++ b/lms/djangoapps/courseware/tests/test_course_info.py @@ -68,12 +68,16 @@ class CourseInfoTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCase, self.assertNotIn("You are not currently enrolled in this course", resp.content) # TODO: LEARNER-611: If this is only tested under Course Info, does this need to move? - def test_redirection_missing_enterprise_consent(self): + @mock.patch('openedx.features.enterprise_support.api.enterprise_customer_for_request') + def test_redirection_missing_enterprise_consent(self, mock_enterprise_customer_for_request): """ Verify that users viewing the course info who are enrolled, but have not provided data sharing consent, are first redirected to a consent page, and then, once they've provided consent, are able to view the course info. """ + # ENT-924: Temporary solution to replace sensitive SSO usernames. + mock_enterprise_customer_for_request.return_value = None + self.setup_user() self.enroll(self.course) diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 91d22ce92c..d304b427f6 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -2596,10 +2596,14 @@ class EnterpriseConsentTestCase(EnterpriseTestConsentRequired, ModuleStoreTestCa CourseOverview.load_from_module_store(self.course.id) CourseEnrollmentFactory(user=self.user, course_id=self.course.id) - def test_consent_required(self): + @patch('openedx.features.enterprise_support.api.enterprise_customer_for_request') + def test_consent_required(self, mock_enterprise_customer_for_request): """ Test that enterprise data sharing consent is required when enabled for the various courseware views. """ + # ENT-924: Temporary solution to replace sensitive SSO usernames. + mock_enterprise_customer_for_request.return_value = None + course_id = unicode(self.course.id) for url in ( reverse("courseware", kwargs=dict(course_id=course_id)), diff --git a/lms/djangoapps/discussion/tests/test_views.py b/lms/djangoapps/discussion/tests/test_views.py index eaa16956d1..a3448bacb2 100644 --- a/lms/djangoapps/discussion/tests/test_views.py +++ b/lms/djangoapps/discussion/tests/test_views.py @@ -1659,10 +1659,14 @@ class EnterpriseConsentTestCase(EnterpriseTestConsentRequired, ForumsEnableMixin self.addCleanup(translation.deactivate) - def test_consent_required(self, mock_request): + @patch('openedx.features.enterprise_support.api.enterprise_customer_for_request') + def test_consent_required(self, mock_enterprise_customer_for_request, mock_request): """ Test that enterprise data sharing consent is required when enabled for the various discussion views. """ + # ENT-924: Temporary solution to replace sensitive SSO usernames. + mock_enterprise_customer_for_request.return_value = None + thread_id = 'dummy' course_id = unicode(self.course.id) mock_request.side_effect = make_mock_request_impl(course=self.course, text='dummy', thread_id=thread_id) diff --git a/lms/djangoapps/support/views/contact_us.py b/lms/djangoapps/support/views/contact_us.py index b8753e3448..197a8bac7a 100644 --- a/lms/djangoapps/support/views/contact_us.py +++ b/lms/djangoapps/support/views/contact_us.py @@ -33,7 +33,7 @@ class ContactUsView(View): if request.user.is_authenticated(): context['user_enrollments'] = CourseEnrollment.enrollments_for_user_with_overviews_preload(request.user) - enterprise_learner_data = enterprise_api.get_enterprise_learner_data(site=request.site, user=request.user) + enterprise_learner_data = enterprise_api.get_enterprise_learner_data(request.user) if enterprise_learner_data: tags.append('enterprise_learner') diff --git a/lms/templates/courseware/progress.html b/lms/templates/courseware/progress.html index 0945c6b5f5..f80738146b 100644 --- a/lms/templates/courseware/progress.html +++ b/lms/templates/courseware/progress.html @@ -11,7 +11,14 @@ from django.core.urlresolvers import reverse from django.conf import settings from django.utils.http import urlquote_plus from six import text_type + +from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name %> + +<% +username = get_enterprise_learner_generic_name(request) or student.username +%> + <%block name="bodyclass">view-in-course view-progress <%block name="headextra"> @@ -54,7 +61,7 @@ from six import text_type % endif

- ${_("Course Progress for Student '{username}' ({email})").format(username=student.username, email=student.email)} + ${_("Course Progress for Student '{username}' ({email})").format(username=username, email=student.email)}

diff --git a/lms/templates/header/user_dropdown.html b/lms/templates/header/user_dropdown.html index 9d1c04c791..73bb1e8820 100644 --- a/lms/templates/header/user_dropdown.html +++ b/lms/templates/header/user_dropdown.html @@ -2,32 +2,29 @@ <%page expression_filter="h"/> <%namespace name='static' file='static_content.html'/> -## This template should not use the target student's details when masquerading, see TNL-4895 -<% -self.real_user = getattr(user, 'real_user', user) -%> - <%! from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_urls_for_user from openedx.core.djangoapps.user_api.accounts.utils import retrieve_last_sitewide_block_completed - +from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name %> <% - profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium'] - username = self.real_user.username - resume_block = retrieve_last_sitewide_block_completed(username) +## This template should not use the target student's details when masquerading, see TNL-4895 +self.real_user = getattr(user, 'real_user', user) +profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium'] +username = self.real_user.username +resume_block = retrieve_last_sitewide_block_completed(username) +displayname = get_enterprise_learner_generic_name(request) or username %> -