summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorankitjavalkar2019-04-23 11:13:01 +0530
committerGitHub2019-04-23 11:13:01 +0530
commit6184d53d7f83739b662a8af8d3c9ea458011c253 (patch)
treeadfd3d538f29e4002cde55301f74bdeb1c5aa45c /yaksh/views.py
parenteac34f9a8fc69e07efd31b005ce296f9071b8a46 (diff)
parent7a60f93b461f79d05947188567468d584a64023b (diff)
downloadonline_test-6184d53d7f83739b662a8af8d3c9ea458011c253.tar.gz
online_test-6184d53d7f83739b662a8af8d3c9ea458011c253.tar.bz2
online_test-6184d53d7f83739b662a8af8d3c9ea458011c253.zip
Merge pull request #599 from prathamesh920/csv-upload-fix
Fix user CSV upload issue
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index d634e0c..7202826 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -2224,18 +2224,15 @@ 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,
@@ -2285,13 +2282,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):