diff --git a/src/tjts5901/templates/listBid.html b/src/tjts5901/templates/listBid.html index bfb322146908b57d1288b058a8dd37b1880f6e07..38c1d1e20e2b38793a5e5932e6ea365da8c0f7d3 100644 --- a/src/tjts5901/templates/listBid.html +++ b/src/tjts5901/templates/listBid.html @@ -20,7 +20,7 @@ <small>{{ item.created_at }}</small> </div> <p class="mb-1">{{ item.description }}</p> - <small>{{ item.starting_bid }}</small> + <small>{{ item.current_price}}</small> <a href="{{ url_for('views.page_bid', id=item.id) }}"><button class="btn btn-primary">Bid</button></a> </div> <div class="row justify-content-md-center"> diff --git a/src/tjts5901/templates/view.html b/src/tjts5901/templates/view.html index 820d6cd22f90b9c526c7c802f1cb3cd7e5c8b6bb..0e4ab5991a351c73d25e44c255372471980c31bd 100644 --- a/src/tjts5901/templates/view.html +++ b/src/tjts5901/templates/view.html @@ -18,9 +18,9 @@ <h5 class="mb-1">{{ item.title }}</h5> <p class="mb-1">{{ item.description }}</p> <p class="mb-1">Created : {{ item.created_at }}</p> - <p class="mb-1">Current bid : {{ item.starting_bid }}</p><br/> + <p class="mb-1">Current bid : {{ current_price }}</p><br/> <form method="POST" action="{{ url_for('views.bid', id=item.id)}}" class="row" enctype="multipart/form-data"> - <input class="col-md-9" id="bid" name ="bid" type="number" min="{{ item.starting_bid }}" placeholder="write your bid"> + <input class="col-md-9" id="bid" name ="bid" type="number" min="{{ min_bid }}" placeholder="write your bid"> <button for="bid" type="submit" class="btn btn-primary col-md-3">Validate</button> </form> </div> diff --git a/src/tjts5901/views.py b/src/tjts5901/views.py index 2350c42c06d419ce9c41592b6ad084995918a039..3a0cd6ee75388b631a99ec522ad9ce1d992eee1f 100644 --- a/src/tjts5901/views.py +++ b/src/tjts5901/views.py @@ -168,6 +168,7 @@ def list_bid(): for item in items: item.image_base64 = base64.b64encode(item.image.read()).decode('utf-8') + item.current_price = get_item_price(item) - MIN_BID_INCREMENT html = render_template("listBid.html", items=items) return html @@ -207,7 +208,7 @@ def bid(id): ) bid.save() except Exception as exc: - flash(("Error placing bid: %(exc)s", exc=exc)) + flash(_("Error placing bid: %(exc)s", exc=exc)) else: flash(("Bid placed successfully!")) @@ -319,11 +320,16 @@ def page_bid(id): item = Item.objects.get_or_404(id=id) + # Set the current price for the bid according to current highest bid + winning_bid = get_winning_bid(item) + min_bid = get_item_price(item) + current_price = min_bid - MIN_BID_INCREMENT + item.image_base64 = base64.b64encode(item.image.read()).decode('utf-8') # Dark pattern to show enticing message to user #if item.closes_at < datetime.utcnow() + timedelta(hours=1): # flash("This item is closing soon! Act now! Now! Now!") - return render_template('view.html', item=item) + return render_template('view.html', item=item, current_price=current_price, min_bid=min_bid)