summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authormaheshgudi2016-08-08 16:07:25 +0530
committermaheshgudi2016-08-29 14:03:05 +0530
commitb259e65bbadc62a9368238e778af5c205b32f5f6 (patch)
treec446ca55fa38294993b679e4874ff4edfd45f10b /yaksh/views.py
parent9a9eb0d9d73cea1bdc6f8ff38631eb4bb664813b (diff)
downloadonline_test-b259e65bbadc62a9368238e778af5c205b32f5f6.tar.gz
online_test-b259e65bbadc62a9368238e778af5c205b32f5f6.tar.bz2
online_test-b259e65bbadc62a9368238e778af5c205b32f5f6.zip
made UI changes to courses page and teacher can add another teacher
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py35
1 files changed, 14 insertions, 21 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index e1ec44e..a2f6f9a 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -664,8 +664,10 @@ def courses(request):
if not is_moderator(user):
raise Http404('You are not allowed to view this page')
courses = Course.objects.filter(creator=user, is_trial=False)
- return my_render_to_response('yaksh/courses.html', {'courses': courses},
- context_instance=ci)
+ allotted_courses = Course.objects.filter(teachers=user, is_trial=False)
+ context = {'courses': courses, "allotted_courses": allotted_courses}
+ return my_render_to_response('yaksh/courses.html', context,
+ context_instance=ci)
@login_required
@@ -1164,7 +1166,7 @@ def search_teacher(request, course_id):
raise Http404('You are not allowed to view this page!')
context = {}
- 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)
context['course'] = course
if request.method == 'POST':
@@ -1196,16 +1198,20 @@ def add_teacher(request, course_id):
raise Http404('You are not allowed to view this page!')
context = {}
- 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)
context['course'] = course
if request.method == 'POST':
teacher_ids = request.POST.getlist('check')
teachers = User.objects.filter(id__in=teacher_ids)
- add_to_group(teachers)
- course.add_teachers(*teachers)
- context['status'] = True
- context['teachers_added'] = teachers
+ 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."
+
return my_render_to_response('yaksh/addteacher.html', context,
context_instance=ci)
else:
@@ -1213,19 +1219,6 @@ def add_teacher(request, course_id):
context_instance=ci)
-@login_required
-def allotted_courses(request):
- """ show courses allotted to a user """
-
- user = request.user
- ci = RequestContext(request)
- if not is_moderator(user):
- raise Http404('You are not allowed to view this page!')
-
- courses = Course.objects.filter(teachers=user)
- return my_render_to_response('yaksh/courses.html', {'courses': courses},
- context_instance=ci)
-
@login_required
def remove_teachers(request, course_id):