summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorPalaparthy Adityachandra2020-05-24 22:04:33 +0530
committerGitHub2020-05-24 22:04:33 +0530
commit372a7c56adaeabee374f9fd9268f1ebf0e082265 (patch)
treeb5244f4a650293e5c099513405c43959c413891d /yaksh/views.py
parentfa656e1ce81c748b354e19e6d5b8de672a58c186 (diff)
parent708839e795f31fb382841e8b3d1c5fc580b22aec (diff)
downloadonline_test-372a7c56adaeabee374f9fd9268f1ebf0e082265.tar.gz
online_test-372a7c56adaeabee374f9fd9268f1ebf0e082265.tar.bz2
online_test-372a7c56adaeabee374f9fd9268f1ebf0e082265.zip
Merge pull request #716 from FOSSEE/fix_issues
Updates and Fixes
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index e4a9038..ca827ac 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -237,12 +237,9 @@ def add_question(request, question_id=None):
qform = QuestionForm(request.POST, instance=question)
fileform = FileForm(request.POST, request.FILES)
remove_files_id = request.POST.getlist('clear')
- files = request.FILES.getlist('file_field')
+ added_files = request.FILES.getlist('file_field')
extract_files_id = request.POST.getlist('extract')
hide_files_id = request.POST.getlist('hide')
- if files:
- for file in files:
- FileUpload.objects.get_or_create(question=question, file=file)
if remove_files_id:
files = FileUpload.objects.filter(id__in=remove_files_id)
for file in files:
@@ -267,12 +264,16 @@ def add_question(request, question_id=None):
request.POST, request.FILES, instance=question
)
)
- files = request.FILES.getlist('file_field')
if qform.is_valid():
question = qform.save(commit=False)
question.user = user
question.save()
# many-to-many field save function used to save the tags
+ if added_files:
+ for file in added_files:
+ FileUpload.objects.get_or_create(
+ question=question, file=file
+ )
qform.save_m2m()
for formset in formsets:
if formset.is_valid():