summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2016-04-29 15:53:00 +0530
committeradityacp2016-04-29 15:53:00 +0530
commit78795446d89ae5c247f5424d70d652437c93cda6 (patch)
tree26ba7a6d92878844a25d988cb57112f287b7a85c /yaksh
parentd2affe68e84da54dc99d9876ab359ad448aa6828 (diff)
downloadonline_test-78795446d89ae5c247f5424d70d652437c93cda6.tar.gz
online_test-78795446d89ae5c247f5424d70d652437c93cda6.tar.bz2
online_test-78795446d89ae5c247f5424d70d652437c93cda6.zip
function name change
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/views.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 4b87431..5cc9f99 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -70,12 +70,12 @@ def has_profile(user):
""" check if user has profile """
return True if hasattr(user, 'profile') else False
-def add_teachers_to_group(teachers):
- """ add teachers to moderator group """
- for teacher in teachers:
- if not is_moderator(teacher):
- group = Group.objects.get(name="moderator")
- teacher.groups.add(group)
+def add_to_group(users):
+ """ add users to moderator group """
+ group = Group.objects.get(name="moderator")
+ for user in users:
+ if not is_moderator(user):
+ user.groups.add(group)
def index(request):
"""The start page.
@@ -1106,7 +1106,7 @@ def add_teacher(request, course_id):
if request.method == 'POST':
teacher_ids = request.POST.getlist('check')
teachers = User.objects.filter(id__in=teacher_ids)
- add_teachers_to_group(teachers)
+ add_to_group(teachers)
course.add_teachers(*teachers)
context['status'] = True
context['teachers_added'] = teachers
@@ -1142,5 +1142,6 @@ def remove_teachers(request, course_id):
course = get_object_or_404(Course, creator=user, pk=course_id)
if request.method == "POST":
teacher_ids = request.POST.getlist('remove')
- course.remove_teachers(*teacher_ids)
+ teachers = User.objects.filter(id__in=teacher_ids)
+ course.remove_teachers(*teachers)
return my_redirect('/exam/manage/courses')