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 %}
-
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)
--
cgit
From d9f6a93ea8d4ddf9f139649567bd680e3f101556 Mon Sep 17 00:00:00 2001
From: maheshgudi
Date: Tue, 9 Aug 2016 18:12:25 +0530
Subject: modified add search and remove_teachers functions
---
yaksh/views.py | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/yaksh/views.py b/yaksh/views.py
index c1dde5f..4944691 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1171,21 +1171,16 @@ def search_teacher(request, course_id):
if request.method == 'POST':
u_name = request.POST.get('uname')
- if len(u_name) == 0:
- return my_render_to_response('yaksh/addteacher.html', context,
- context_instance=ci)
- else:
+ if not len(u_name) == 0:
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(id=course.creator.id))
context['success'] = True
context['teachers'] = teachers
- return my_render_to_response('yaksh/addteacher.html', context,
- context_instance=ci)
- else:
- return my_render_to_response('yaksh/addteacher.html', context,
- context_instance=ci)
+
+ return my_render_to_response('yaksh/addteacher.html', context,
+ context_instance=ci)
@login_required
@@ -1199,8 +1194,9 @@ def add_teacher(request, course_id):
raise Http404('You are not allowed to view this page!')
context = {}
- course = get_object_or_404(Course, Q(creator=user)|Q(teachers=user), pk=course_id)
- context['course'] = course
+ course = get_object_or_404(Course, pk=course_id)
+ if user == course.creator or user in course.teachers.all():
+ context['course'] = course
if request.method == 'POST':
teacher_ids = request.POST.getlist('check')
@@ -1220,10 +1216,10 @@ def remove_teachers(request, course_id):
""" remove user from a course """
user = request.user
- if not is_moderator(user):
+ course = get_object_or_404(Course, pk=course_id)
+ if not is_moderator(user) and (user == course.creator or user in course.teachers.all()):
raise Http404('You are not allowed to view this page!')
- 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)
--
cgit
From 80e3a68ddfcc15fc88442d7af53d804653c4d2a4 Mon Sep 17 00:00:00 2001
From: maheshgudi
Date: Tue, 9 Aug 2016 18:13:22 +0530
Subject: added Course and question paper classes in admin.py
---
yaksh/admin.py | 4 ++++
yaksh/models.py | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/yaksh/admin.py b/yaksh/admin.py
index 2ce3ac4..b25c0af 100644
--- a/yaksh/admin.py
+++ b/yaksh/admin.py
@@ -1,10 +1,14 @@
from yaksh.models import Question, Quiz
from yaksh.models import TestCase, StandardTestCase, StdoutBasedTestCase, Course
+from yaksh.models import Question, Quiz, Course, QuestionPaper
+from yaksh.models import TestCase, StandardTestCase, StdoutBasedTestCase
from django.contrib import admin
admin.site.register(Question)
admin.site.register(TestCase)
admin.site.register(StandardTestCase)
admin.site.register(StdoutBasedTestCase)
+admin.site.register(Course)
admin.site.register(Quiz)
admin.site.register(Course)
+admin.site.register(QuestionPaper)
diff --git a/yaksh/models.py b/yaksh/models.py
index 73d4b27..898662c 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -570,7 +570,9 @@ class QuestionPaper(models.Model):
if self.quiz.has_prerequisite():
prerequisite = self._get_prequisite_paper()
return prerequisite._is_questionpaper_passed(user)
-
+
+ def __unicode__(self):
+ return "Question Paper for " + self.quiz.description
###############################################################################
class QuestionSet(models.Model):
--
cgit
From 5d49a64d11d6a6868c74bf9a22bb7cc0fa7b8c6b Mon Sep 17 00:00:00 2001
From: maheshgudi
Date: Mon, 29 Aug 2016 13:53:41 +0530
Subject: changed template; modified search_teacher, add_teacher and
remove_teachers view functions
---
yaksh/templates/yaksh/courses.html | 4 +++-
yaksh/views.py | 9 +++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html
index 5e2266c..42f49d1 100644
--- a/yaksh/templates/yaksh/courses.html
+++ b/yaksh/templates/yaksh/courses.html
@@ -141,9 +141,11 @@
{% endfor %}
+{% else %}
+
No new Courses allotted
{% endif %}
+
{% if courses or allotted_courses %}
-
{% endif %}
{% endblock %}
diff --git a/yaksh/views.py b/yaksh/views.py
index 4944691..16454b2 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1166,9 +1166,12 @@ def search_teacher(request, course_id):
raise Http404('You are not allowed to view this page!')
context = {}
- course = get_object_or_404(Course, Q(creator=user)|Q(teachers=user), pk=course_id)
+ course = get_object_or_404(Course, pk=course_id)
context['course'] = course
+ if user != course.creator and user not in course.teachers.all():
+ raise Http404('You are not allowed to view this page!')
+
if request.method == 'POST':
u_name = request.POST.get('uname')
if not len(u_name) == 0:
@@ -1197,6 +1200,8 @@ def add_teacher(request, course_id):
course = get_object_or_404(Course, pk=course_id)
if user == course.creator or user in course.teachers.all():
context['course'] = course
+ else:
+ raise Http404('You are not allowed to view this page!')
if request.method == 'POST':
teacher_ids = request.POST.getlist('check')
@@ -1217,7 +1222,7 @@ def remove_teachers(request, course_id):
user = request.user
course = get_object_or_404(Course, pk=course_id)
- if not is_moderator(user) and (user == course.creator or user in course.teachers.all()):
+ if not is_moderator(user) and (user != course.creator and user not in course.teachers.all()):
raise Http404('You are not allowed to view this page!')
if request.method == "POST":
--
cgit
From b8c58435aef3b9c30ae8952f353648d70d228eec Mon Sep 17 00:00:00 2001
From: maheshgudi
Date: Mon, 29 Aug 2016 14:11:13 +0530
Subject: minor changes in admin
---
yaksh/admin.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/yaksh/admin.py b/yaksh/admin.py
index b25c0af..4ef2f3d 100644
--- a/yaksh/admin.py
+++ b/yaksh/admin.py
@@ -10,5 +10,4 @@ admin.site.register(StandardTestCase)
admin.site.register(StdoutBasedTestCase)
admin.site.register(Course)
admin.site.register(Quiz)
-admin.site.register(Course)
admin.site.register(QuestionPaper)
--
cgit