- return direct_to_template(request, 'explorer/panels/xmleditor.html', extra_context={
- 'text': text,
- })
-
-
-def gallery_panel(request, path):
- return direct_to_template(request, 'explorer/panels/gallery.html', extra_context={
- 'form': forms.ImageFoldersForm(),
- })
-
-
-def htmleditor_panel(request, path):
- return direct_to_template(request, 'explorer/panels/htmleditor.html', extra_context={
- 'html': html.transform(repo.get_file(path).data(), is_file=False),
- })
-
-
-def dceditor_panel(request, path):
- if request.method == 'POST':
- form = forms.DublinCoreForm(request.POST)
- if form.is_valid():
- form.save(repo, path)
- repo.commit(message='%s: DublinCore edited' % path)
- else:
- text = repo.get_file(path).data()
- form = forms.DublinCoreForm(text=text)
+ # return direct_to_template(request, 'explorer/file_list.html', extra_context={
+ # 'files': files, 'bookform': bookform,
+ # })
+
+@permission_required('api.document.can_add')
+def file_upload(request):
+ from api.resources import library_resource
+ from api.forms import DocumentUploadForm
+ from django.http import HttpRequest, HttpResponseRedirect
+
+ response = library_resource.handler.create(request)
+
+ if isinstance(response, HttpResponse):
+ data = json.loads(response.content)
+
+ if response.status_code == 201:
+ return HttpResponseRedirect( \
+ reverse("editor_view", args=[ data['name'] ]) )
+ else:
+ bookform = DocumentUploadForm(request.POST, request.FILES)
+ bookform.is_valid()
+
+ return direct_to_template(request, 'explorer/file_upload.html',
+ extra_context={'bookform': bookform } )
+