From e9b89d77ac585c8d95d2fcb5ce12316557f07e4a Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 19 May 2017 16:02:43 +0530 Subject: Change attachment response in views.py --- yaksh/views.py | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index c7af5cc..eb7a103 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -281,31 +281,6 @@ def add_quiz(request, course_id, quiz_id=None): context, context_instance=ci) - -@login_required -@email_verified -def show_all_questionpapers(request, questionpaper_id=None): - user = request.user - ci = RequestContext(request) - if not user.is_authenticated() or not is_moderator(user): - raise Http404('You are not allowed to view this page!') - - if questionpaper_id is None: - qu_papers = QuestionPaper.objects.filter(is_trial=False) - context = {'papers': qu_papers} - return my_render_to_response('yaksh/showquestionpapers.html', context, - context_instance=ci) - else: - qu_papers = QuestionPaper.objects.get(id=questionpaper_id) - quiz = qu_papers.quiz - fixed_questions = qu_papers.get_ordered_questions() - random_questions = qu_papers.random_questions.all() - context = {'quiz': quiz, 'fixed_questions': fixed_questions, - 'random_questions': random_questions} - return my_render_to_response('yaksh/editquestionpaper.html', context, - context_instance=ci) - - @login_required @email_verified def prof_manage(request, msg=None): @@ -893,7 +868,6 @@ def ajax_questions_filter(request): if language != "select": filter_dict['language'] = str(language) - questions = list(Question.objects.filter(**filter_dict)) return my_render_to_response('yaksh/ajax_question_filter.html', @@ -1053,8 +1027,8 @@ def show_all_questions(request): question = Question() zip_file = question.dump_questions(question_ids, user) response = HttpResponse(content_type='application/zip') - response['Content-Disposition'] = '''attachment;\ - filename={0}_questions.zip'''.format(user) + response['Content-Disposition'] = dedent(\ + '''attachment; filename={0}_questions.zip'''.format(user)) zip_file.seek(0) response.write(zip_file.read()) return response @@ -1589,8 +1563,7 @@ def download_assignment_file(request, quiz_id, question_id=None, user_id=None): zip_file.close() zipfile_name.seek(0) response = HttpResponse(content_type='application/zip') - response['Content-Disposition'] = '''attachment;\ - filename={0}.zip'''.format( + response['Content-Disposition'] = 'attachment; filename={0}.zip'.format( file_name.replace(" ", "_") ) response.write(zipfile_name.read()) -- cgit From 29d21f48f1392cd00ddef6a3be3531c58b2a8770 Mon Sep 17 00:00:00 2001 From: Date: Thu, 25 May 2017 13:09:12 +0530 Subject: Add check for verifying moderator --- yaksh/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index eb7a103..5c52fa7 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1070,7 +1070,6 @@ def user_data(request, user_id, questionpaper_id=None): return my_render_to_response('yaksh/user_data.html', context, context_instance=RequestContext(request)) - @login_required @email_verified def download_csv(request, questionpaper_id): @@ -1545,6 +1544,8 @@ def update_email(request): @email_verified def download_assignment_file(request, quiz_id, question_id=None, user_id=None): user = request.user + if not is_moderator(user): + raise Http404("You are not allowed to view this page") qp = QuestionPaper.objects.get(quiz_id=quiz_id) assignment_files, file_name = AssignmentUpload.objects.get_assignments(qp, question_id, -- cgit