summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
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):