예제 #1
0
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']))
예제 #2
0
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)
    )
예제 #3
0
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))