示例#1
0
def order_add_book_asin(request):
    """Adds a book with the ASIN passed via POST. Used for AJAX book adds of
       books that were found in Amazon"""
    try:
        book = Book.get_book(request.POST['ASIN'])
        order_add_book(request, book)
        return order_render_as_response(request)
    except amazonproduct.InvalidParameterValue:
        # this ASIN isn't found, so return 404-not-found error message
        raise Http404('No book with that ASIN found on Amazon')
示例#2
0
def order_add_book_isbn(request):
    """Same as order_add_book_asin except it does additional ISBN format checking"""
    if (isbn.isValid(isbn.isbn_strip(request.POST['ISBN']))):
        try:
            book = Book.get_book(isbn.isbn_strip(request.POST['ISBN']))
            order_add_book(request, book)
            return order_render_as_response(request)
        except amazonproduct.InvalidParameterValue:
            # this ASIN isn't found, so return 404-not-found error message
            raise Http404('No book with that ISBN found on Amazon')
    else:
        # this ASIN isn't well-formatted, so return 400-bad-request error message
        return HttpResponseBadRequest()