X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;f=filex%2Fuploadhandler.py;h=7e57a369b4923324199e39274f17a1dac9ab8706;hb=0531413dff86618983d7c6ae2f723b5051029e1b;hp=c2414eeb3eda5e025b2862c567378d97df466187;hpb=edd1abec6c3948dd007a7a7d75ddcc28e9197e41;p=qcg-portal.git diff --git a/filex/uploadhandler.py b/filex/uploadhandler.py index c2414ee..7e57a36 100644 --- a/filex/uploadhandler.py +++ b/filex/uploadhandler.py @@ -1,9 +1,7 @@ -from functools import wraps import os from django.core.files.uploadedfile import UploadedFile from django.core.files.uploadhandler import FileUploadHandler, StopUpload, StopFutureHandlers -from django.views.decorators.csrf import csrf_exempt, csrf_protect from filex.forms import HostPathForm from filex.ftp import FTPOperation @@ -25,7 +23,8 @@ class FtpUploadHandler(FileUploadHandler): if self.ftp is None: self.ftp = FTPOperation(self.request.session['proxy'], self.chunk_size) - self.url = 'gsiftp://' + form.cleaned_data['host'] + os.path.join(form.cleaned_data['path'], self.file_name) + self.url = 'gsiftp://{}/{}'.format(form.cleaned_data['host'], + os.path.join(form.cleaned_data['path'], self.file_name)) self.tmp_url = self.url + '.part' self.ftp.put(self.tmp_url) @@ -44,13 +43,3 @@ class FtpUploadHandler(FileUploadHandler): return UploadedFile(name=self.file_name, size=file_size, charset=self.charset, content_type=self.content_type, content_type_extra=self.content_type_extra) - - -def with_ftp_upload_handler(view_func): - @wraps(view_func) - def wrapped_view(request, *args, **kwargs): - request.upload_handlers = [FtpUploadHandler(request)] - - return csrf_protect(view_func)(request, *args, **kwargs) - - return csrf_exempt(wrapped_view)