+# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
import json
import os
from urllib.parse import quote
return super(UploadView, self).dispatch(request, *args, **kwargs)
def get(self, request, *args, **kwargs):
- if request.is_ajax():
+ if request.headers.get('x-requested-with') == 'XMLHttpRequest':
files = []
path = self.get_safe_path()
if os.path.isdir(path):
quote(f.encode('utf-8'))),
'delete_type': "DELETE"
})
- thumbnail_url = thumbnail(self.get_directory() + f),
files.append(file_info)
- return JSONResponse(files)
+ return JSONResponse({"files": files})
else:
return super(UploadView, self).get(request, *args, **kwargs)
quote(f.name.encode('utf-8'))),
'delete_type': "DELETE"
})
- response = JSONResponse(data)
+ response = JSONResponse({"files": data})
response['Content-Disposition'] = 'inline; filename=files.json'
return response