summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/templates/yaksh/addteacher.html11
-rw-r--r--yaksh/templates/yaksh/courses.html4
-rw-r--r--yaksh/views.py21
3 files changed, 11 insertions, 25 deletions
diff --git a/yaksh/templates/yaksh/addteacher.html b/yaksh/templates/yaksh/addteacher.html
index 2ab107b..6722a52 100644
--- a/yaksh/templates/yaksh/addteacher.html
+++ b/yaksh/templates/yaksh/addteacher.html
@@ -19,12 +19,6 @@
</div>
<br><br>
-{% if message %}
-<div class="alert alert-danger">
- <strong>Sorry!</strong> {{message}}
-</div>
-{% endif %}
-
<form action="{{ URL_ROOT }}/exam/manage/addteacher/{{ course.id }}/" method="post">
{% csrf_token %}
{% if success == True %}
@@ -63,10 +57,7 @@
</form>
{% if status == True %}
<div class="row">
- <div class="span6 offset4 wrap">
- <div class="alert alert-success">
- <strong>Congrats!</strong> Following Teachers have been added:
-</div>
+ <div class="span6 offset4 wrap">
{% if teachers_added %}
{% for teacher in teachers_added %}
<div class="well">
diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html
index 1c68472..5e2266c 100644
--- a/yaksh/templates/yaksh/courses.html
+++ b/yaksh/templates/yaksh/courses.html
@@ -11,9 +11,9 @@
{% block manage %}
{% if not courses %}
- <center><h4> No new Courses added </h4></center>
+ <center><h4> No new Courses created </h4></center>
{% else %}
-<center><h3> Course(s) Added</h3></center>
+<center><h3> Course(s) Created</h3></center>
{% for course in courses %}
<div class="row show-grid">
<div class="span14">
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)