diff options
author | Cheese Cookie | 2013-11-10 15:41:28 +0530 |
---|---|---|
committer | Cheese Cookie | 2013-11-10 15:41:28 +0530 |
commit | 2d7d913fd6d8f77915d040ac45908a5cdd0d2b68 (patch) | |
tree | cfbf2a5250f2a7a489b83b4f4b208a1dbd533b14 /scipy/views.py | |
parent | 00b410eb6484ce274259bebf71f8cba95e6d879d (diff) | |
download | SciPy2013-2d7d913fd6d8f77915d040ac45908a5cdd0d2b68.tar.gz SciPy2013-2d7d913fd6d8f77915d040ac45908a5cdd0d2b68.tar.bz2 SciPy2013-2d7d913fd6d8f77915d040ac45908a5cdd0d2b68.zip |
rewriting entire upload validatian
Diffstat (limited to 'scipy/views.py')
-rw-r--r-- | scipy/views.py | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/scipy/views.py b/scipy/views.py index c48dc11..7bb53a1 100644 --- a/scipy/views.py +++ b/scipy/views.py @@ -88,37 +88,17 @@ def upload_document(request): if request.user.is_authenticated(): if request.method == 'POST': form = DocumentUploadForm(request.POST, request.FILES) - attachment = request.FILES['attachments'] - content_type = attachment.content_type.split('/')[1] - content_size = attachment.size - if not content_type in allowed_files: - invalid_file_msg = "Only PDF, DOC, DOCX & TXT files are allowed" - context['invalid_file'] = invalid_file_msg - context['form'] = form - context.update(csrf(request)) - return render_to_response('upload-document.html', context) - elif content_size > 5242880: - large_file_msg = "File size exceeds 5MB" - context['large_file'] = large_file_msg - context['form'] = form - context.update(csrf(request)) - return render_to_response('upload-document.html', context) - elif form.is_valid(): + if form.is_valid(): data = form.save(commit=False) data.user = request.user data.verified = False data.save() return HttpResponseRedirect("/2013/call-for-proposals/?status=up") - else: - context = {} - context.update(csrf(request)) - context['form'] = form - context['current_user'] = request.user - return render_to_response('upload-document.html', context) else: form = DocumentUploadForm() context.update(csrf(request)) - context['form'] = DocumentUploadForm() + context['form'] = form return render_to_response('upload-document.html', context) else: return HttpResponseRedirect('/2013/accounts/login') + |