From d70303a8933a006c31c5984bb2f350a125fcb4fe Mon Sep 17 00:00:00 2001
From: atesker <andrewtr@gmail.com>
Date: Tue, 30 Jun 2020 09:35:04 -0400
Subject: [PATCH] EDUCATOR-5127 - update message

---
 lms/djangoapps/teams/csv.py              | 8 ++------
 lms/djangoapps/teams/tests/test_views.py | 3 +--
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/lms/djangoapps/teams/csv.py b/lms/djangoapps/teams/csv.py
index f4a873b3511..c23f7ddb2e4 100644
--- a/lms/djangoapps/teams/csv.py
+++ b/lms/djangoapps/teams/csv.py
@@ -371,16 +371,12 @@ class TeamMembershipImportManager(object):
         if(teamset_id, team_name) not in self.user_enrollment_by_team:
             self.user_enrollment_by_team[teamset_id, team_name] = set()
         self.user_enrollment_by_team[teamset_id, team_name].add(self.user_to_actual_enrollment_mode[user.id])
-        if self.is_FERPA_bubble_breached(teamset_id, team_name):
+        if self.is_FERPA_bubble_breached(teamset_id, team_name) or \
+                not self.is_enrollment_protection_for_existing_team_matches_user(user, team_name, teamset_id):
             error_message = \
                 'Team {} cannot have Master’s track users mixed with users in other tracks.'.format(team_name)
             self.add_error_and_check_if_max_exceeded(error_message)
             return False
-        if not self.is_enrollment_protection_for_existing_team_matches_user(user, team_name, teamset_id):
-            error_message = \
-                'User {} does not have access to team {}.'.format(user.username, team_name)
-            self.add_error_and_check_if_max_exceeded(error_message)
-            return False
         return True
 
     def is_enrollment_protection_for_existing_team_matches_user(self, user, team_name, teamset_id):
diff --git a/lms/djangoapps/teams/tests/test_views.py b/lms/djangoapps/teams/tests/test_views.py
index 4b110a05fd9..b5f5ff5ef2f 100644
--- a/lms/djangoapps/teams/tests/test_views.py
+++ b/lms/djangoapps/teams/tests/test_views.py
@@ -3101,8 +3101,7 @@ class TestBulkMembershipManagement(TeamAPITestCase):
             user='staff'
         )
         response_text = json.loads(response.content.decode('utf-8'))
-        expected_message = 'User {} does not have access to team {}.'.format(
-            masters_a,
+        expected_message = 'Team {} cannot have Master’s track users mixed with users in other tracks.'.format(
             team.name
         )
         self.assertEqual(response_text['errors'][0], expected_message)
-- 
GitLab