- other_errors = []
- if request.method == 'POST':
- form = forms.BookUploadForm(request.POST, request.FILES)
- if form.is_valid():
- try:
- # prepare the data
- f = request.FILES['file']
- decoded = f.read().decode('utf-8')
- fileid = form.cleaned_data['bookname'].lower()
- rpath = file_path(fileid)
-
- if form.cleaned_data['autoxml']:
- decoded = librarian.wrap_text(decoded, unicode(date.today()) )
-
- def upload_action():
- repo._add_file(rpath, decoded.encode('utf-8') )
- repo._commit(message="File %s uploaded by user %s" % \
- (rpath, request.user.username), user=request.user.username)
-
- repo.in_branch(upload_action, 'default')
+ from api.resources import library_resource
+ from api.forms import DocumentUploadForm
+ from django.http import HttpRequest, HttpResponseRedirect