From 570b141055f9baa27c539842b14756838949ba60 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Wed, 26 Aug 2020 18:51:25 +0530 Subject: Avoid duplicate user entry with same email address during upload. Django allows multiple usernames with same email id. Preventing this, as we identify users with their email id or username. --- yaksh/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 3adb536..9f8468d 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2409,8 +2409,10 @@ def _read_user_csv(request, reader, course): messages.info(request, "{0} -- Missing Values".format(counter)) continue users = User.objects.filter(username=username) + if not users.exists(): + users = User.objects.filter(email=email) if users.exists(): - user = users[0] + user = users.last() if remove.strip().lower() == 'true': _remove_from_course(user, course) messages.info(request, "{0} -- {1} -- User rejected".format( -- cgit