From 4af929fb8b30f9cb0cc382c801b33b7370f55402 Mon Sep 17 00:00:00 2001
From: Jillian Vogel <jill@opencraft.com>
Date: Tue, 3 Apr 2018 23:26:28 +0930
Subject: [PATCH] Fixes test failures

---
 .../student/tests/test_activate_account.py    | 31 +++++++++----------
 common/djangoapps/student/views/dashboard.py  | 22 ++++++-------
 2 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/common/djangoapps/student/tests/test_activate_account.py b/common/djangoapps/student/tests/test_activate_account.py
index 62430bf4324..e32f6c78b4e 100644
--- a/common/djangoapps/student/tests/test_activate_account.py
+++ b/common/djangoapps/student/tests/test_activate_account.py
@@ -121,32 +121,29 @@ class TestActivateAccount(TestCase):
         """
         # Log in with test user.
         self.login()
-        expected_message = render_to_string(
-            'registration/account_activation_sidebar_notice.html',
-            {
-                'email': self.user.email,
-                'platform_name': self.platform_name,
-                'activation_email_support_link': self.activation_email_support_link
-            }
+        expected_message = (
+            u"Check your {email_start}{email}{email_end} inbox for an account activation link from "
+            u"{platform_name}. If you need help, contact {link_start}{platform_name} Support{link_end}."
+        ).format(
+            platform_name=self.platform_name,
+            email_start="<strong>",
+            email_end="</strong>",
+            email=self.user.email,
+            link_start="<a target='_blank' href='{activation_email_support_link}'>".format(
+                activation_email_support_link=self.activation_email_support_link,
+            ),
+            link_end="</a>",
         )
 
         response = self.client.get(reverse('dashboard'))
-        self.assertContains(response, expected_message, html=True)
+        self.assertContains(response, expected_message)
 
         # Now make sure account activation message goes away when user activated the account
         self.user.is_active = True
         self.user.save()
         self.login()
-        expected_message = render_to_string(
-            'registration/account_activation_sidebar_notice.html',
-            {
-                'email': self.user.email,
-                'platform_name': self.platform_name,
-                'activation_email_support_link': self.activation_email_support_link
-            }
-        )
         response = self.client.get(reverse('dashboard'))
-        self.assertNotContains(response, expected_message, html=True)
+        self.assertNotContains(response, expected_message)
 
     def test_account_activation_notification_on_logistration(self):
         """
diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py
index 2e41f2fc6d7..9bdefe56ebd 100644
--- a/common/djangoapps/student/views/dashboard.py
+++ b/common/djangoapps/student/views/dashboard.py
@@ -611,17 +611,17 @@ def student_dashboard(request):
     activate_account_message = ''
     if not user.is_active:
         activate_account_message = Text(_(
-          "Check your {email_start}{email}{email_end} inbox for an account activation link from {platform_name}. "
-          "If you need help, contact {link_start}{platform_name} Support{link_end}."
+            "Check your {email_start}{email}{email_end} inbox for an account activation link from {platform_name}. "
+            "If you need help, contact {link_start}{platform_name} Support{link_end}."
         )).format(
-          platform_name=platform_name,
-          email_start=HTML("<strong>"),
-          email_end=HTML("</strong>"),
-          email=user.email,
-          link_start=HTML("<a target='_blank' href='{activation_email_support_link}'>").format(
-            activation_email_support_link=activation_email_support_link,
-          ),
-          link_end=HTML("</a>"),
+            platform_name=platform_name,
+            email_start=HTML("<strong>"),
+            email_end=HTML("</strong>"),
+            email=user.email,
+            link_start=HTML("<a target='_blank' href='{activation_email_support_link}'>").format(
+                activation_email_support_link=activation_email_support_link,
+            ),
+            link_end=HTML("</a>"),
         )
 
     enterprise_message = get_dashboard_consent_notification(request, user, course_enrollments)
@@ -819,7 +819,7 @@ def student_dashboard(request):
         '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,
-        'display_sidebar_account_activation_message': (not user.is_active and not hide_dashboard_courses_until_activated),
+        'display_sidebar_account_activation_message': not(user.is_active or hide_dashboard_courses_until_activated),
         'display_dashboard_courses': (user.is_active or not hide_dashboard_courses_until_activated),
         'empty_dashboard_message': empty_dashboard_message,
     }
-- 
GitLab