Пример #1
0
def sell_form(request):   
    from search.utils import search_by_isbn
    from book.utils import add_links
    result = {}
    if request.method == 'GET':
        isbn = request.GET.get("isbn","0")
        isbn = isbn.lstrip()
        isbn = isbn.rstrip()
        if validate_isbn(isbn=isbn):
            isbn = re.sub("[^0-9Xx]", "", isbn)
            isbn = convert_to_13(isbn=isbn)
            results = search_by_isbn(query=isbn, thumb=False)["books"]
            if results:
                result["book"] = results[0]
                add_links(result["book"])
                return render(request, 'sell_form.html', result)
        return render(request, 'search_empty.html', {"query": isbn})
    return render(request, "error_page.html")   
Пример #2
0
def sell_edit(request):
    from sell.models import get_offer_info, get_auction_info
    from utils import get_book_info
    from book.utils import add_links
    result = {}
    if request.method == 'POST':  
        is_auction = request.POST.get("is_auction", "")
        offerid = request.POST.get("offer_id", "0")
        if is_auction:
            offer = get_auction_info(auction_id=offerid)
        else:
            offer = get_offer_info(offer_id=offerid)
        isbn = offer["isbn"]
        result = get_book_info(isbn=isbn)
        add_links(result["book"])
        result["offer"] = offer 
        result["offer_id"] = offerid
        result["is_auction"] = is_auction
        return render(request, "sell_form_edit.html", result)
    else:
        return render(request, "error_page.html")