def addbookbyisbn(request): from tools import isbntools isbnform = ISBNBookForm(request.POST) if isbnform.is_valid(): try: internalapi.import_by_isbn(isbnform.cleaned_data['isbn']) except Exception: return HttpResponse("something went wrong. could not import data for ISBN %s" % isbnform.cleaned_data['isbn']) else: return HttpResponseRedirect("/book/edit/"+isbntools.strip(isbnform.cleaned_data['isbn']))
def addbook(request): from tools import isbntools if request.method == "POST": form = BookForm(request.POST, request.FILES) if form.is_valid(): return HttpResponseRedirect('/book/'+isbntools.strip(str(form.cleaned_data['isbn']))) else: form = BookForm() return render_to_response('addbook.html', {'form': form, 'isbnform': ISBNBookForm(request.POST)}, context_instance=RequestContext(request) )
def import_by_isbn(isbn): if isbntools.valid_isbn13(isbn): isbndb_importer.do_import(isbntools.strip(isbn)) else: isbndb_importer.do_import(isbntools.convert(isbn))