From c3dd2ec955c5a2b46ea469d1aff0d3b8c1859e2e Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 16 Sep 2016 20:29:06 +0530 Subject: changed views to get demo course --- yaksh/views.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/yaksh/views.py b/yaksh/views.py index 6644705..6d5ac30 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -256,8 +256,9 @@ 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 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 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!') context = {} if request.method == "POST": if quiz_id is None: @@ -683,12 +684,16 @@ def courses(request): raise Http404('You are not allowed to view this page') try: demo_user = User.objects.get(username="yaksh_demo_user") - except User.DoesNotExist: + demo_course = Course.objects.get(creator=demo_user) + except User.DoesNotExist, Course.DoesNotExist: demo_user = None - courses = Course.objects.filter(Q(creator=user) | Q(creator=demo_user), - is_trial=False) + demo_course = None + + courses = Course.objects.filter(creator=user, is_trial=False) allotted_courses = Course.objects.filter(teachers=user, is_trial=False) - context = {'courses': courses, "allotted_courses": allotted_courses} + + context = {'courses': courses, "allotted_courses": allotted_courses, + 'demo_course': demo_course} return my_render_to_response('yaksh/courses.html', context, context_instance=ci) -- cgit