From f4b6bf5349c3916321a5ed3d67159548b4bb56ce Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 20 Jul 2018 12:36:05 +0530 Subject: Raise 404 error if course and question paper are not available --- yaksh/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 444b324..8ccc12b 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2101,13 +2101,13 @@ def update_email(request): def download_assignment_file(request, quiz_id, course_id, question_id=None, user_id=None): user = request.user - course = Course.objects.get(id=course_id) + course = get_object_or_404(Course, pk=course_id) if (not course.is_creator(user) and not course.is_teacher(user) and not course.is_student(user)): raise Http404("You are not allowed to download files for {0}".format( course.name) ) - qp = QuestionPaper.objects.get(quiz_id=quiz_id) + qp = get_object_or_404(QuestionPaper, quiz_id=quiz_id) assignment_files, file_name = AssignmentUpload.objects.get_assignments( qp, question_id, user_id, course_id ) -- cgit