Exemple #1
0
def auction_detail(request, pk, bidform=BidForm()):
    activate(get_current_language(request))
    auction = Auction.objects.get(pk=pk)
    bids = auction.bid_set.all()

    displayRate = get_display_rate(request)

    dropDownHTML = curr.dropDownElementHelper(reverse('currency_change'), request.path)

    if request.user.is_authenticated():
        is_owner = Auction.isOwner(auction.pk, request.user.pk)
    else:
        is_owner = False

    if not bids:
        maxBidPrice = auction.minPrice
    else:
        maxbid = max(bids, key=lambda b: b.price)
        maxBidPrice = maxbid.price

    if auction.isResolved():
        winner =  auction.get_highest_bid()
    else:
        winner = None
    return render(request, 'auction/auction_detail.html',
                  {'auction': auction, 'form': bidform, 'bids': bids.order_by('-price'), 'maxbid': maxBidPrice, 'is_owner': is_owner,
                   'dropdown': dropDownHTML, 'displayRate': displayRate, 'winner' : winner})
Exemple #2
0
def welcome_view(request, auction=Auction.listAuction()):
    activate(get_current_language(request))
    auction = Auction.excludeBanned(auction)

    displayRate = get_display_rate(request)

    dropDownHTML = curr.dropDownElementHelper(reverse('currency_change'), request.path)

    if request.user.is_authenticated():
        return render(request, 'auction/auction_list.html',
                      {'username': request.user.username, 'auctions': auction, 'dropdown': dropDownHTML,
                       'displayRate': displayRate})
    else:
        return render(request, 'auction/auction_list.html',
                      {'auctions': auction, 'dropdown': dropDownHTML, 'displayRate': displayRate})