+class UploadView(UploadViewMixin, FormView):
+ template_name = "fileupload/picture_form.html"
+ form_class = UploadForm
+
+ def get_object(self, request, *args, **kwargs):
+ """Get any data for later use."""
+ return None
+
+ def get_directory(self):
+ """Directory relative to MEDIA_ROOT. Must end with a slash."""
+ return self.kwargs['path']
+
+ def breadcrumbs(self):
+ """List of tuples (name, url) or just (name,) for breadcrumbs.
+
+ Probably only the last item (representing currently browsed dir)
+ should lack url.
+
+ """
+ directory = self.get_directory()
+ now_path = os.path.dirname(self.request.get_full_path())
+ directory = os.path.dirname(directory)
+ if directory:
+ crumbs = [
+ (os.path.basename(directory),)
+ ]
+ directory = os.path.dirname(directory)
+ now_path = (os.path.dirname(now_path))
+ while directory:
+ crumbs.insert(0, (os.path.basename(directory), now_path + '/'))
+ directory = os.path.dirname(directory)
+ now_path = os.path.dirname(now_path)
+ crumbs.insert(0, ('media', now_path))
+ else:
+ crumbs = [('media',)]
+ return crumbs
+
+ def get_url(self, filename):
+ """Finds URL of a file in browsed dir."""
+ return settings.MEDIA_URL + self.get_directory() + quote(filename.encode('utf-8'))
+
+ @method_decorator(vary_on_headers('Accept'))