summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2016-09-19 14:47:09 +0530
committeradityacp2016-09-19 14:47:09 +0530
commit4bc766cb85fd999a8e2ac6d7e87e62730edb1244 (patch)
treeb9fb896d2893d016e7e0919a3c58eb1998e53d8b /yaksh
parent89376074f8dcee778dfc43587d623d4e8d1b5520 (diff)
downloadonline_test-4bc766cb85fd999a8e2ac6d7e87e62730edb1244.tar.gz
online_test-4bc766cb85fd999a8e2ac6d7e87e62730edb1244.tar.bz2
online_test-4bc766cb85fd999a8e2ac6d7e87e62730edb1244.zip
removed string comparison for demo course
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/test_views.py9
-rw-r--r--yaksh/views.py12
2 files changed, 15 insertions, 6 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 4f9b18d..e88956c 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -650,9 +650,12 @@ class TestCourses(TestCase):
self.client = Client()
self.mod_group = Group.objects.create(name='moderator')
- User.objects.get_or_create(username='demo_user',
- password='demo',
- email='demo@test.com')
+ user = User.objects.get_or_create(username='yaksh_demo_user',
+ password='demo',
+ email='demo@test.com')
+ course = Course.objects.get_or_create(name="Yaksh Demo course",
+ enrollment="open",
+ creator=user[0])
# Create Moderator with profile
self.user1_plaintext_pass = 'demo1'
self.user1 = User.objects.create_user(
diff --git a/yaksh/views.py b/yaksh/views.py
index 6d5ac30..3e42b64 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -256,9 +256,15 @@ def add_quiz(request, course_id, quiz_id=None):
user = request.user
course = get_object_or_404(Course, pk=course_id)
ci = RequestContext(request)
- if course.name != "Yaksh_Demo_course":
- if not is_moderator(user) or (user != course.creator and user not in course.teachers.all()):
- raise Http404('You are not allowed to view this page!')
+ if not is_moderator(user):
+ raise Http404('You are not allowed to view this page!')
+ try:
+ demo_user = User.objects.get(username="yaksh_demo_user")
+ except User.DoesNotExist:
+ demo_user = None
+ if course.creator != demo_user:
+ if (user != course.creator and user not in course.teachers.all()):
+ raise Http404('You are not allowed to view this course !')
context = {}
if request.method == "POST":
if quiz_id is None: