From 69ab40cc3d4d769d0d3f1c783f950cac52f7935e Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 16 Mar 2017 17:15:38 +0530 Subject: Fix test cases for loading questions --- yaksh/models.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/yaksh/models.py b/yaksh/models.py index dc015d5..c10f953 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -318,18 +318,17 @@ class Question(models.Model): file_names = question.pop('files') test_cases = question.pop('testcase') que, result = Question.objects.get_or_create(**question) - if not result: - if file_names: - que._add_files_to_db(file_names, file_path) - for test_case in test_cases: - test_case_type = test_case.pop('test_case_type') - model_class = get_model_class(test_case_type) - new_test_case, obj_create_status = \ - model_class.objects.get_or_create( - question=que, **test_case - ) - new_test_case.type = test_case_type - new_test_case.save() + if file_names: + que._add_files_to_db(file_names, file_path) + for test_case in test_cases: + test_case_type = test_case.pop('test_case_type') + model_class = get_model_class(test_case_type) + new_test_case, obj_create_status = \ + model_class.objects.get_or_create( + question=que, **test_case + ) + new_test_case.type = test_case_type + new_test_case.save() if files_list: delete_files(files_list, file_path) -- cgit