X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;ds=sidebyside;f=filex%2Fviews.py;fp=filex%2Fviews.py;h=1a02ddb483b6c38a4a270382f4a93751acdf5e95;hb=2e226ed0e2a8bbf0cedbcaf5fff9e2906e858588;hp=68c9ad988ed937f6714506cd101bca6b785c91be;hpb=a968d1a54ba12336da3f05bfee5317721c563443;p=qcg-portal.git diff --git a/filex/views.py b/filex/views.py index 68c9ad9..1a02ddb 100644 --- a/filex/views.py +++ b/filex/views.py @@ -186,3 +186,26 @@ def move(request): msg = form.errors return JsonResponse({'msg': msg}, status=400) + + +@require_POST +def compress(request): + check_auth(request) + + # TODO data validation + host = request.POST.get('host') + path = request.POST.get('path') + files = request.POST.getlist('files') + archive = request.POST.get('archive') + if not host or not path or not files: + raise SuspiciousOperation("No path or host or files or archive given!") + + server = 'gsiftp://' + host + + try: + # consume generator with command output + list(FTPOperation(request.session['proxy']).compress(server, path, files, archive)) + except FTPException as e: + return JsonResponse({'msg': e.message}, status=400) + else: + return JsonResponse({'success': True})