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' %} ...@@ -12,6 +12,15 @@ a{% extends 'boodlesite\templates\base.html' %}
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-lg-7 col-md-6"> <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 product display div
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel"> <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
...@@ -56,11 +65,11 @@ a{% extends 'boodlesite\templates\base.html' %} ...@@ -56,11 +65,11 @@ a{% extends 'boodlesite\templates\base.html' %}
<p>{{ item_specs }}</p> <p>{{ item_specs }}</p>
</div> </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> 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"> aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
...@@ -74,25 +83,15 @@ a{% extends 'boodlesite\templates\base.html' %} ...@@ -74,25 +83,15 @@ a{% extends 'boodlesite\templates\base.html' %}
<div class="modal-body"> <div class="modal-body">
<form action="" method="POST"> <form action="" method="POST">
<div class="form-group"> <div class="form-group">
<h1>Current Highest Bid: PHP {{highest_bid.amount}}</h1> <h3>Current Highest Bid: PHP {{highest_bid.amount}}</h3>
<label for="recipient-name" class="col-form-label">Enter Bid amount:</label>
{% csrf_token %} {% csrf_token %}
{{ form }} {{ form }}
{% if form.amount.errors %}
<ol>
{% for error in form.amount.errors %}
<li><strong>{{ error|escape }}</strong></li>
{% endfor %}
</ol>
{% endif %}
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-secondary" name="Submit"> Submit </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> </div>
</form> </form>
...@@ -100,7 +99,9 @@ a{% extends 'boodlesite\templates\base.html' %} ...@@ -100,7 +99,9 @@ a{% extends 'boodlesite\templates\base.html' %}
</div> </div>
</div> </div>
<!-- latest bids / history -->
<!-- latest bids / history -->
<h1>Latest Bids</h1>
<ul class="cards"> <ul class="cards">
{% if auction_bids %} {% if auction_bids %}
......
...@@ -6,4 +6,14 @@ from .models import * ...@@ -6,4 +6,14 @@ from .models import *
class PlaceBidForm(forms.ModelForm): class PlaceBidForm(forms.ModelForm):
class Meta: class Meta:
model = AuctionBid model = AuctionBid
fields = ['amount'] fields = ['amount']
\ No newline at end of file
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
...@@ -44,10 +44,6 @@ def auction(request, pk): ...@@ -44,10 +44,6 @@ def auction(request, pk):
highest_bid = auction_item.floorprice highest_bid = auction_item.floorprice
else: else:
highest_bid = auction_bids[0] highest_bid = auction_bids[0]
print("This is the auction bids: ", auction_bids)
prev_amt = AuctionBid.objects.latest('amount');
print(prev_amt)
form = PlaceBidForm() form = PlaceBidForm()
if request.method == 'POST': if request.method == 'POST':
...@@ -58,16 +54,14 @@ def auction(request, pk): ...@@ -58,16 +54,14 @@ def auction(request, pk):
new_bid = AuctionBid(amount=amount,bidtime=datetime.now(),auctionid=auction) new_bid = AuctionBid(amount=amount,bidtime=datetime.now(),auctionid=auction)
new_bid.save() new_bid.save()
return redirect(f"/auction/{pk}") return redirect(f"/auction/{pk}")
else:
raise ValidationError("ERROR")
context = { context = {
'item_name':auction_item.itemname, 'item_name':auction_item.itemname,
'item_specs': auction_item.itemspecs, 'item_specs': auction_item.itemspecs,
'auction_bids' : auction_bids, 'auction_bids' : auction_bids,
'item_floor_price': auction_item.floorprice, 'item_floor_price': auction_item.floorprice,
'highest_bid':highest_bid, 'highest_bid': highest_bid,
'auction_end': auction.auctionend,
'form' : form '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