diff options
author | ankitjavalkar | 2016-05-25 18:31:46 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-07-08 12:36:46 +0530 |
commit | 4cd9882c2e0e294b86e447e769bea6f66f69ff28 (patch) | |
tree | 9723cb64c04e032c493a94dbc4471c099470c60f /yaksh/views.py | |
parent | 47a1d4589b9f549892939f62879604713dbe772a (diff) | |
download | online_test-4cd9882c2e0e294b86e447e769bea6f66f69ff28.tar.gz online_test-4cd9882c2e0e294b86e447e769bea6f66f69ff28.tar.bz2 online_test-4cd9882c2e0e294b86e447e769bea6f66f69ff28.zip |
Add further tests for views
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 87e8bf6..56746b0 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -69,7 +69,7 @@ def get_user_dir(user): def is_moderator(user): """Check if the user is having moderator rights""" - if user.groups.filter(name='moderator').count() == 1: + if user.groups.filter(name='moderator').exists(): return True def add_to_group(users): @@ -219,7 +219,6 @@ def edit_question(request, question_id=None): def add_quiz(request, quiz_id=None): """To add a new quiz in the database. Create a new quiz and store it.""" - user = request.user ci = RequestContext(request) if not is_moderator(user): @@ -612,7 +611,10 @@ def enroll_request(request, course_id): ci = RequestContext(request) course = get_object_or_404(Course, pk=course_id) course.request(user) - return my_redirect('/exam/manage/') + if is_moderator(user): + return my_redirect('/exam/manage/') + else: + return my_redirect('/exam/quizzes/') @login_required @@ -623,7 +625,10 @@ def self_enroll(request, course_id): if course.is_self_enroll(): was_rejected = False course.enroll(was_rejected, user) - return my_redirect('/exam/manage/') + if is_moderator(user): + return my_redirect('/exam/manage/') + else: + return my_redirect('/exam/quizzes/') @login_required |