diff options
author | ankitjavalkar | 2016-05-02 14:38:13 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-05-09 11:51:06 +0530 |
commit | d953f6f9e62671eeb5d6ea6498475167301dfe91 (patch) | |
tree | ca172e52de5e8dd04e97ce7acfa16ab577ab9d58 /yaksh/views.py | |
parent | 23b7abd3c1125e4c875e214e4f673c48c4bf4752 (diff) | |
download | online_test-d953f6f9e62671eeb5d6ea6498475167301dfe91.tar.gz online_test-d953f6f9e62671eeb5d6ea6498475167301dfe91.tar.bz2 online_test-d953f6f9e62671eeb5d6ea6498475167301dfe91.zip |
- Fix tests
- Fix minor views.py
- Fix minor errors caused due to conflict resolution, rebasing
- Fix errors in forms, views
- Minor Button label change in addquestion.html
- Add snippet to question
- Remove commented code
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index ffb08d8..2a3adbf 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -153,7 +153,9 @@ def add_question(request): if request.method == "POST" and 'save_question' in request.POST: question_form = QuestionForm(request.POST) if question_form.is_valid(): - new_question = question_form.save() + new_question = question_form.save(commit=False) + new_question.user = user + new_question.save() return my_redirect("/exam/manage/addquestion/{0}".format(new_question.id)) else: return my_render_to_response('yaksh/add_question.html', @@ -190,6 +192,11 @@ def edit_question(request, question_id=None): test_case_formset.save() return my_redirect("/exam/manage/addquestion/{0}".format(new_question.id)) else: + test_case_type = question_form.cleaned_data.get('test_case_type') + test_case_form_class = get_object_form(model=test_case_type, exclude_fields=['question']) + test_case_model_class = get_model_class(test_case_type) + TestCaseInlineFormSet = inlineformset_factory(Question, test_case_model_class, form=test_case_form_class, extra=1) + test_case_formset = TestCaseInlineFormSet(request.POST, request.FILES, instance=question_instance) return my_render_to_response('yaksh/add_question.html', {'form': question_form, 'test_case_formset': test_case_formset, |