diff options
author | adityacp | 2020-02-17 13:28:01 +0530 |
---|---|---|
committer | adityacp | 2020-02-17 13:28:01 +0530 |
commit | 8b0fb468fd94565b359f3c5bf2f2b694e7a9c97a (patch) | |
tree | 07e8df762c518881b44556578fe3b5349b31a73c /yaksh/views.py | |
parent | 5eae1a6c6ebba23179052f87b50c2cb34dd62d05 (diff) | |
parent | 3995f0a05fe3e681a21116c158708598db0ada08 (diff) | |
download | online_test-8b0fb468fd94565b359f3c5bf2f2b694e7a9c97a.tar.gz online_test-8b0fb468fd94565b359f3c5bf2f2b694e7a9c97a.tar.bz2 online_test-8b0fb468fd94565b359f3c5bf2f2b694e7a9c97a.zip |
Fix conflicts
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 6a0794f..d1e8b7b 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -224,12 +224,12 @@ def add_question(request, question_id=None): user = request.user test_case_type = None - if question_id is None: - question = Question(user=user) - question.save() - else: + if question_id is not None: question = Question.objects.get(id=question_id) - + uploaded_files = FileUpload.objects.filter(question_id=question.id) + else: + question = None + uploaded_files = [] if request.method == "POST" and 'delete_files' in request.POST: remove_files_id = request.POST.getlist('clear') if remove_files_id: @@ -267,7 +267,6 @@ def add_question(request, question_id=None): ) ) files = request.FILES.getlist('file_field') - uploaded_files = FileUpload.objects.filter(question_id=question.id) if qform.is_valid(): question = qform.save(commit=False) question.user = user @@ -278,6 +277,7 @@ def add_question(request, question_id=None): if formset.is_valid(): formset.save() test_case_type = request.POST.get('case_type', None) + uploaded_files = FileUpload.objects.filter(question_id=question.id) else: context = { 'qform': qform, @@ -286,13 +286,10 @@ def add_question(request, question_id=None): 'formsets': formsets, 'uploaded_files': uploaded_files } - return my_render_to_response( - request, "yaksh/add_question.html", context - ) + return render(request, "yaksh/add_question.html", context) qform = QuestionForm(instance=question) fileform = FileForm() - uploaded_files = FileUpload.objects.filter(question_id=question.id) formsets = [] for testcase in TestCase.__subclasses__(): if test_case_type == testcase.__name__.lower(): @@ -311,9 +308,8 @@ def add_question(request, question_id=None): ) context = {'qform': qform, 'fileform': fileform, 'question': question, 'formsets': formsets, 'uploaded_files': uploaded_files} - return my_render_to_response( - request, "yaksh/add_question.html", context - ) + + return render(request, "yaksh/add_question.html", context) @login_required |