diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/test_views.py | 9 | ||||
-rw-r--r-- | yaksh/views.py | 12 |
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: |