diff options
author | King | 2019-04-16 12:17:04 +0530 |
---|---|---|
committer | King | 2019-04-17 21:07:20 +0530 |
commit | 23f0364a7b1724ae69165537df5aa68916ed3e0a (patch) | |
tree | b5802a7fec97b1422427ae472e7d89e3c0379b6f /yaksh/views.py | |
parent | 0c8b272aa25210d71e03715c1209402d2b770a98 (diff) | |
download | online_test-23f0364a7b1724ae69165537df5aa68916ed3e0a.tar.gz online_test-23f0364a7b1724ae69165537df5aa68916ed3e0a.tar.bz2 online_test-23f0364a7b1724ae69165537df5aa68916ed3e0a.zip |
Fix user CSV upload issue
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 9199a3a..5d9d5db 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2216,18 +2216,14 @@ def _read_user_csv(reader, course): if users.exists(): user = users[0] if remove.strip().lower() == 'true': - if _remove_from_course(user, course): - upload_details.append("{0} -- {1} -- User rejected".format( - counter, user.username)) - continue + _remove_from_course(user, course) + upload_details.append("{0} -- {1} -- User rejected".format( + counter, user.username)) else: - if _add_to_course(user, course): - upload_details.append("{0} -- {1} -- User rejected".format( - counter, user.username)) - if user not in course.get_enrolled(): - upload_details.append("{0} -- {1} not added to course".format( - counter, user)) - continue + _add_to_course(user, course) + upload_details.append("{0} -- {1} -- User Added Successfully".format( + counter, user.username)) + continue user_defaults = {'email': email, 'first_name': first_name, 'last_name': last_name} user, created = _create_or_update_user(username, password, @@ -2277,13 +2273,15 @@ def _get_csv_values(row, fields): def _remove_from_course(user, course): if user in course.get_enrolled(): course.reject(True, user) - return True + else: + course.rejected.add(user) def _add_to_course(user, course): if user in course.get_rejected(): course.enroll(True, user) - return True + else: + course.students.add(user) def _create_or_update_user(username, password, defaults): |