diff options
author | maheshgudi | 2016-08-09 11:32:19 +0530 |
---|---|---|
committer | maheshgudi | 2016-08-29 14:03:05 +0530 |
commit | 29c50ad458de008b0672d0f2b1c64278a963850c (patch) | |
tree | bb48f88d899fed7fd1547842eb9b3067f0ce3be3 /yaksh/views.py | |
parent | b259e65bbadc62a9368238e778af5c205b32f5f6 (diff) | |
download | online_test-29c50ad458de008b0672d0f2b1c64278a963850c.tar.gz online_test-29c50ad458de008b0672d0f2b1c64278a963850c.tar.bz2 online_test-29c50ad458de008b0672d0f2b1c64278a963850c.zip |
changed search_teacher function to exclude course creator
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index a2f6f9a..c1dde5f 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1177,7 +1177,8 @@ def search_teacher(request, course_id): else: teachers = User.objects.filter(Q(username__icontains=u_name)| Q(first_name__icontains=u_name)|Q(last_name__icontains=u_name)| - Q(email__icontains=u_name)).exclude(Q(id=user.id)|Q(is_superuser=1)) + Q(email__icontains=u_name)).exclude(Q(id=user.id)|Q(is_superuser=1)| + Q(id=course.creator.id)) context['success'] = True context['teachers'] = teachers return my_render_to_response('yaksh/addteacher.html', context, @@ -1204,18 +1205,12 @@ def add_teacher(request, course_id): if request.method == 'POST': teacher_ids = request.POST.getlist('check') teachers = User.objects.filter(id__in=teacher_ids) - if not course.creator in teachers: - add_to_group(teachers) - course.add_teachers(*teachers) - context['status'] = True - context['teachers_added'] = teachers - else: - context["message"] = "You cannot add course creator as teacher." + add_to_group(teachers) + course.add_teachers(*teachers) + context['status'] = True + context['teachers_added'] = teachers - return my_render_to_response('yaksh/addteacher.html', context, - context_instance=ci) - else: - return my_render_to_response('yaksh/addteacher.html', context, + return my_render_to_response('yaksh/addteacher.html', context, context_instance=ci) @@ -1228,7 +1223,7 @@ def remove_teachers(request, course_id): if not is_moderator(user): raise Http404('You are not allowed to view this page!') - course = get_object_or_404(Course, creator=user, pk=course_id) + course = get_object_or_404(Course, Q(creator=user)|Q(teachers=user), pk=course_id) if request.method == "POST": teacher_ids = request.POST.getlist('remove') teachers = User.objects.filter(id__in=teacher_ids) |