From 46ed93807c3175bbb0693a06fe28ba8792d25208 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 30 Sep 2016 11:49:19 -0400 Subject: [PATCH] Review feedback and actual fix TIL about defining variables in Mako templates. --- lms/djangoapps/courseware/tests/test_masquerade.py | 8 ++++---- lms/djangoapps/courseware/views/index.py | 2 +- lms/templates/user_dropdown.html | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lms/djangoapps/courseware/tests/test_masquerade.py b/lms/djangoapps/courseware/tests/test_masquerade.py index 014413931b..ba36397c00 100644 --- a/lms/djangoapps/courseware/tests/test_masquerade.py +++ b/lms/djangoapps/courseware/tests/test_masquerade.py @@ -149,16 +149,16 @@ class MasqueradeTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase): self.assertIn(self.problem_display_name, problem_html) self.assertEqual(show_answer_expected, "Show Answer" in problem_html) - def verify_original_user_profile_link(self): + def verify_real_user_profile_link(self): """ Verifies that the 'Profile' link in the navigation dropdown is pointing - to the original user. + to the real user. """ content = self.get_courseware_page().content self.assertIn( 'Profile'.format(self.test_user.username), content, - "Profile link should point to original user", + "Profile link should point to real user", ) @@ -339,7 +339,7 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi self.assertEqual(self.get_progress_detail(), u'2/2') # Verify that the user dropdown links have not changed - self.verify_original_user_profile_link() + self.verify_real_user_profile_link() # Temporarily override the student state. self.submit_answer('Correct', 'Incorrect') diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index 95ea747448..3b3668924b 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -384,6 +384,7 @@ class CoursewareIndex(View): 'staff_access': self.is_staff, 'studio_url': get_studio_url(self.course, 'course'), 'masquerade': self.masquerade, + 'real_user': self.real_user, 'xqa_server': settings.FEATURES.get('XQA_SERVER', "http://your_xqa_server.com"), 'bookmarks_api_url': reverse('bookmarks'), 'language_preference': self._get_language_preference(), @@ -406,7 +407,6 @@ class CoursewareIndex(View): courseware_context['entrance_exam_passed'] = user_has_passed_entrance_exam(self.request, self.course) # staff masquerading data - courseware_context['real_user'] = self.real_user now = datetime.now(UTC()) effective_start = _adjust_start_date_for_beta_testers(self.effective_user, self.course, self.course_key) if not in_preview_mode() and self.is_staff and now < effective_start: diff --git a/lms/templates/user_dropdown.html b/lms/templates/user_dropdown.html index f8fdfb7086..7dd31d2585 100644 --- a/lms/templates/user_dropdown.html +++ b/lms/templates/user_dropdown.html @@ -4,7 +4,7 @@ ## This template should not use the target student's details when masquerading, see TNL-4895 <% -original_user = real_user or user +self.real_user = real_user if real_user != UNDEFINED else user %> <%! @@ -19,8 +19,8 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_ ${_("Dashboard for:")} <% - username = original_user.username - profile_image_url = get_profile_image_urls_for_user(original_user)['medium'] + username = self.real_user.username + profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium'] %> ${username} @@ -33,7 +33,7 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_