From b16da9b9ddc55156e9b9cdbf440489267f133e97 Mon Sep 17 00:00:00 2001 From: Varsha Menon Date: Tue, 27 Aug 2024 13:30:13 -0400 Subject: [PATCH] fix: add logger warning for dupe --- .../apps/core/management/commands/bulk_add_course_staff.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/edx_exams/apps/core/management/commands/bulk_add_course_staff.py b/edx_exams/apps/core/management/commands/bulk_add_course_staff.py index 34a55fc9..63228c08 100644 --- a/edx_exams/apps/core/management/commands/bulk_add_course_staff.py +++ b/edx_exams/apps/core/management/commands/bulk_add_course_staff.py @@ -68,9 +68,15 @@ def add_course_staff_from_csv(self, csv_file, batch_size, batch_delay): for i in range(0, len(reader), batch_size): users_list = [] for row in reader[i:i + batch_size]: + username = row.get('username') + email = row.get('email') try: users_list.append(User.objects.get_or_create(username=row.get('username'), email=row.get('email'))) except IntegrityError: + logger.warning( + f'User with username={username} and email={email} was not created due to an existing duplicate ' + f'user with username.' + ) continue users_dict = dict([(u.username, u) for (u, c) in users_list]) users.update(users_dict)