diff options
author | adityacp | 2017-03-16 17:15:38 +0530 |
---|---|---|
committer | adityacp | 2017-03-16 17:15:38 +0530 |
commit | 69ab40cc3d4d769d0d3f1c783f950cac52f7935e (patch) | |
tree | 267e343f6cafbaa77b86515ea9b2e1418cf3c7c3 /yaksh/models.py | |
parent | eb3afa3b86ca7a129c9d1365e0ae7946b0c25d32 (diff) | |
download | online_test-69ab40cc3d4d769d0d3f1c783f950cac52f7935e.tar.gz online_test-69ab40cc3d4d769d0d3f1c783f950cac52f7935e.tar.bz2 online_test-69ab40cc3d4d769d0d3f1c783f950cac52f7935e.zip |
Fix test cases for loading questions
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 23 |
1 files 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) |