Displayed auctionend countdown in date, time format.

Displayed error message and edited forms and views accordingly.
Edited auction.html to display these.
Co-authored-by: 's avatarpinkboheme <pinkboheme@users.noreply.github.com>
Co-authored-by: 's avatarChristine <cdeeerrr@users.noreply.github.com>
parent 82c624f3
......@@ -12,6 +12,15 @@ a{% extends 'boodlesite\templates\base.html' %}
<div class="container">
<div class="row">
<div class="col-lg-7 col-md-6">
<!-- Countdown display-->
<div class="test">
<!-- Format:
Auction ends at: <Date>
Time: <Days>, <Hours>, <Mins>, <Seconds> -->
<h4> Auction ends at: {{ auction_end }} </h4>
</div>
<!--product display -->
product display div
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
......@@ -56,11 +65,11 @@ a{% extends 'boodlesite\templates\base.html' %}
<p>{{ item_specs }}</p>
</div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal"
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#placeBidModal"
data-whatever="@mdo">Place Bid</button>
<h1>Latest Bids</h1>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
<div class="modal fade" id="placeBidModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
......@@ -74,25 +83,15 @@ a{% extends 'boodlesite\templates\base.html' %}
<div class="modal-body">
<form action="" method="POST">
<div class="form-group">
<h1>Current Highest Bid: PHP {{highest_bid.amount}}</h1>
<label for="recipient-name" class="col-form-label">Enter Bid amount:</label>
<h3>Current Highest Bid: PHP {{highest_bid.amount}}</h3>
{% csrf_token %}
{{ form }}
{% if form.amount.errors %}
<ol>
{% for error in form.amount.errors %}
<li><strong>{{ error|escape }}</strong></li>
{% endfor %}
</ol>
{% endif %}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-secondary" name="Submit"> Submit </button>
<!-- {% comment %} <button type="submit" class="btn btn-primary" value="Submit">Confirm Bid</button> {% endcomment %} -->
</div>
</form>
......@@ -100,7 +99,9 @@ a{% extends 'boodlesite\templates\base.html' %}
</div>
</div>
<!-- latest bids / history -->
<h1>Latest Bids</h1>
<ul class="cards">
{% if auction_bids %}
......
......@@ -7,3 +7,13 @@ class PlaceBidForm(forms.ModelForm):
class Meta:
model = AuctionBid
fields = ['amount']
def clean_amount(self):
form_amount = self.cleaned_data.get("amount")
prev_amt = AuctionBid.objects.latest("amount")
prev_amt_cleaned = prev_amt.amount
if prev_amt_cleaned > form_amount:
raise forms.ValidationError("Please Put Higher Bid")
return form_amount
......@@ -45,10 +45,6 @@ def auction(request, pk):
else:
highest_bid = auction_bids[0]
print("This is the auction bids: ", auction_bids)
prev_amt = AuctionBid.objects.latest('amount');
print(prev_amt)
form = PlaceBidForm()
if request.method == 'POST':
form = PlaceBidForm(request.POST)
......@@ -58,16 +54,14 @@ def auction(request, pk):
new_bid = AuctionBid(amount=amount,bidtime=datetime.now(),auctionid=auction)
new_bid.save()
return redirect(f"/auction/{pk}")
else:
raise ValidationError("ERROR")
context = {
'item_name':auction_item.itemname,
'item_specs': auction_item.itemspecs,
'auction_bids' : auction_bids,
'item_floor_price': auction_item.floorprice,
'highest_bid':highest_bid,
'highest_bid': highest_bid,
'auction_end': auction.auctionend,
'form' : form
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment