-@with_repo
-def file_list(request, repo):
- paginator = Paginator( repo.file_list(), 100);
- bookform = forms.BookUploadForm()
-
- try:
- page = int(request.GET.get('page', '1'))
- except ValueError:
- page = 1
-
- try:
- files = paginator.page(page)
- except (EmptyPage, InvalidPage):
- files = paginator.page(paginator.num_pages)
-
- return direct_to_template(request, 'explorer/file_list.html', extra_context={
- 'files': files, 'page': page, 'bookform': bookform,
- })
+def file_list(request):
+ from wiki.views import document_list
+
+ # short-circut the api document list
+ # doctree = library_resource.handler.read(request)
+ # print "DOCTREE:", doctree['documents']
+
+ return document_list(request, 'explorer/file_list.html')
+
+ # 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 } )
+