close bid improved
This commit is contained in:
parent
42e38c6c19
commit
083fcf7b38
Binary file not shown.
|
@ -14,18 +14,42 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4>{{ listing.title }}</h4><br>
|
<h4>{{ listing.title }}</h4><br>
|
||||||
|
|
||||||
|
{% if not listing.closed %}
|
||||||
<p class="card-text" style="font-size: large;">
|
<p class="card-text" style="font-size: medium;">
|
||||||
<b>bid price</b> : ${{listing.price}}<br>
|
{% for bidding in listing.bidding_listing.all %}
|
||||||
|
<b>bid price</b> : ${{bidding.bid_value}}<br>
|
||||||
|
<b>Last bid by</b>: {{bidding.user}}
|
||||||
|
<br>
|
||||||
<b>created by</b>: {{listing.user}}<br>
|
<b>created by</b>: {{listing.user}}<br>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
<small class="text-muted"><i> created on {{listing.date_added}}</i> </small>
|
<small class="text-muted"><i> created on {{listing.date_added}}</i> </small>
|
||||||
</p>
|
</p>
|
||||||
<div class = "text-light">
|
{% else %}
|
||||||
|
<p class="card-text" style="font-size: medium;">
|
||||||
</div>
|
<strong style="color:red;">CLOSED</strong>
|
||||||
|
<br>
|
||||||
|
This listing is over.
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
{% for bidding in listing.bidding_listing.all %}
|
||||||
|
{% if user == bidding.user %}
|
||||||
|
<b>You won this listing!!!</b>
|
||||||
|
{% else %}
|
||||||
|
<b>This is won by <strong style="color:navy;font-size: large;">@{{ bidding.user }}</strong></b>
|
||||||
|
for <strong>${{bidding.bid_value}}</strong>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
<div class = "text-right">
|
<div class = "text-right">
|
||||||
{% if user.is_authenticated %}
|
{% if listing.closed %}
|
||||||
|
|
||||||
|
|
||||||
|
{% elif user.is_authenticated %}
|
||||||
|
|
||||||
<form action="{% url 'watch' listing.title %}" method="POST">
|
<form action="{% url 'watch' listing.title %}" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
|
@ -36,23 +36,17 @@
|
||||||
<h3 style="color:darkgreen;">${{bids.bid_value}} <small style = "color:black;">by</small> <small style="color:navy;">@{{bids.user}}</small></h3>
|
<h3 style="color:darkgreen;">${{bids.bid_value}} <small style = "color:black;">by</small> <small style="color:navy;">@{{bids.user}}</small></h3>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated and user != Listing.user %}
|
||||||
<form action="{% url 'bid' Listing.title %}" method = "POST">
|
<form action="{% url 'bid' Listing.title %}" method = "POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="input-group mb-2">
|
{{ bid_form }}
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text">$</span>
|
|
||||||
</div>
|
|
||||||
<input type="number" name="bid" class="form-control input-sm" aria-label="Amount (to the nearest dollar)" placeholder="Bid a dollar more than price" required="required" min={{bids.bid_value}} step="0.01">
|
|
||||||
<div class="input-group-append">
|
|
||||||
<span class="input-group-text">.00</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<input class="btn btn-primary" type="submit" value="Place Bid">
|
<input class="btn btn-primary" type="submit" value="Place Bid">
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% elif user.is_authenticated and user == Listing.user%}
|
||||||
|
<h5>You can't bid on your own Listing</h5>
|
||||||
|
{% else %}
|
||||||
<br>
|
<br>
|
||||||
<strong>Log In to bid on this Listing</strong>
|
<strong>Log In to bid on this Listing</strong>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from django.contrib.auth import authenticate, login, logout
|
from django.contrib.auth import authenticate, login, logout
|
||||||
|
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
@ -9,11 +10,12 @@ from .models import User,AuctionListing,Comment,Bids
|
||||||
|
|
||||||
categories = ['Fashion','Electronics','Home','Sports','Toys','Automobile','Books','Videogames', 'Other']
|
categories = ['Fashion','Electronics','Home','Sports','Toys','Automobile','Books','Videogames', 'Other']
|
||||||
class Bid_Form(forms.Form):
|
class Bid_Form(forms.Form):
|
||||||
bid = 0.0
|
bid_value = 0.00
|
||||||
def __init__(self,bid_value):
|
def __init__(self, *args, **kwargs):
|
||||||
self.bid = bid_value
|
super(Bid_Form, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['bid'].widget.attrs['min'] = 10
|
||||||
bid_value = forms.DecimalField(decimal_places=2,min_value= bid + 1)
|
|
||||||
|
bid = forms.DecimalField(decimal_places=2)
|
||||||
|
|
||||||
def watch(request,title):
|
def watch(request,title):
|
||||||
if request.method =="POST":
|
if request.method =="POST":
|
||||||
|
@ -46,7 +48,6 @@ def listing(request,title):
|
||||||
"""
|
"""
|
||||||
listing = AuctionListing.objects.get(pk = title)
|
listing = AuctionListing.objects.get(pk = title)
|
||||||
bids = Bids.objects.get(listing = listing)
|
bids = Bids.objects.get(listing = listing)
|
||||||
print(bids)
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
body = request.POST["comment_body"]
|
body = request.POST["comment_body"]
|
||||||
comment = Comment(user=request.user,listing=listing,body = body)
|
comment = Comment(user=request.user,listing=listing,body = body)
|
||||||
|
@ -56,7 +57,8 @@ def listing(request,title):
|
||||||
|
|
||||||
return render(request,"auctions/listing.html",{
|
return render(request,"auctions/listing.html",{
|
||||||
"Listing": listing,
|
"Listing": listing,
|
||||||
"bids" : bids
|
"bids" : bids,
|
||||||
|
"bid_form":Bid_Form(bids.bid_value)
|
||||||
})
|
})
|
||||||
|
|
||||||
def category(request,cat_name = None):
|
def category(request,cat_name = None):
|
||||||
|
@ -140,7 +142,7 @@ def create(request):
|
||||||
starting_bid = request.POST["starting_bid"]
|
starting_bid = request.POST["starting_bid"]
|
||||||
photo_url = request.POST["photo"]
|
photo_url = request.POST["photo"]
|
||||||
if photo_url == "":
|
if photo_url == "":
|
||||||
photo_url = "https://www.riobeauty.co.uk/images/product_image_not_found.gif"
|
photo_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/15/No_image_available_600_x_450.svg/1280px-No_image_available_600_x_450.svg.png"
|
||||||
category = request.POST["category"]
|
category = request.POST["category"]
|
||||||
listing_obj = AuctionListing(title = title, desc = desc, user = request.user,price = starting_bid, picture = photo_url,category=category)
|
listing_obj = AuctionListing(title = title, desc = desc, user = request.user,price = starting_bid, picture = photo_url,category=category)
|
||||||
listing_obj.save()
|
listing_obj.save()
|
||||||
|
@ -161,7 +163,8 @@ def bid(request, title):
|
||||||
bid.user = request.user
|
bid.user = request.user
|
||||||
return render(request,"auctions/listing.html",{
|
return render(request,"auctions/listing.html",{
|
||||||
"Listing": listing,
|
"Listing": listing,
|
||||||
"bids" : bid
|
"bids" : bid,
|
||||||
|
"bid_form":Bid_Form(bid.bid_value)
|
||||||
})
|
})
|
||||||
def close_bid(request,title):
|
def close_bid(request,title):
|
||||||
listing = AuctionListing.objects.get(title=title)
|
listing = AuctionListing.objects.get(title=title)
|
||||||
|
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
Loading…
Reference in New Issue