diff --git a/auctions/__pycache__/models.cpython-37.pyc b/auctions/__pycache__/models.cpython-37.pyc index 41702a2..d3d8c8d 100644 Binary files a/auctions/__pycache__/models.cpython-37.pyc and b/auctions/__pycache__/models.cpython-37.pyc differ diff --git a/auctions/__pycache__/views.cpython-37.pyc b/auctions/__pycache__/views.cpython-37.pyc index 643b3e8..f6b5070 100644 Binary files a/auctions/__pycache__/views.cpython-37.pyc and b/auctions/__pycache__/views.cpython-37.pyc differ diff --git a/auctions/migrations/0002_auctionlisting_closed.py b/auctions/migrations/0002_auctionlisting_closed.py new file mode 100644 index 0000000..4d544ab --- /dev/null +++ b/auctions/migrations/0002_auctionlisting_closed.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.8 on 2020-10-21 11:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('auctions', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='auctionlisting', + name='closed', + field=models.BooleanField(default=False), + ), + ] diff --git a/auctions/migrations/__pycache__/0002_auctionlisting_closed.cpython-37.pyc b/auctions/migrations/__pycache__/0002_auctionlisting_closed.cpython-37.pyc new file mode 100644 index 0000000..a78b398 Binary files /dev/null and b/auctions/migrations/__pycache__/0002_auctionlisting_closed.cpython-37.pyc differ diff --git a/auctions/models.py b/auctions/models.py index 3ef057c..9c4019d 100644 --- a/auctions/models.py +++ b/auctions/models.py @@ -23,6 +23,7 @@ class AuctionListing(models.Model): picture = models.URLField(default="https://www.riobeauty.co.uk/images/product_image_not_found.gif") category = models.CharField(max_length = 64,choices=category_choices) date_added = models.DateTimeField(auto_now_add=True) + closed = models.BooleanField(default=False) def __str__(self): return f"{self.title}: {self.price},{self.desc},{self.picture},{self.category},{self.date_added}" @@ -43,4 +44,3 @@ class Bids(models.Model): def __str__(self): return '%s - %s - %s' % (self.bid_value, self.user, self.listing) - diff --git a/auctions/templates/auctions/index.html b/auctions/templates/auctions/index.html index 56c904e..e369078 100644 --- a/auctions/templates/auctions/index.html +++ b/auctions/templates/auctions/index.html @@ -4,7 +4,7 @@

Active Listings

{% for listing in Listings %} -
+
diff --git a/auctions/templates/auctions/layout.html b/auctions/templates/auctions/layout.html index fb8be93..8e73546 100644 --- a/auctions/templates/auctions/layout.html +++ b/auctions/templates/auctions/layout.html @@ -9,39 +9,51 @@

Auctions

-
+
{% if user.is_authenticated %} Signed in as {{ user.username }}. {% else %} Not signed in. {% endif %}
-
+ + +
+
{% block body %} {% endblock %} diff --git a/auctions/templates/auctions/listing.html b/auctions/templates/auctions/listing.html index d972f28..7ee0945 100644 --- a/auctions/templates/auctions/listing.html +++ b/auctions/templates/auctions/listing.html @@ -25,15 +25,29 @@
-

{{Listing.desc}}

+

{{Listing.desc}}

- -

${{bids.bid_value}}

- bids so far + {% if Listing.closed %} +
+

This listing is CLOSED

+
+

This Listing is won by @{{bids.user}} for ${{bids.bid_value}}

+ {% else %} +

${{bids.bid_value}} by @{{bids.user}}

+ +
{% if user.is_authenticated %}
{% csrf_token %} - +
+
+ $ +
+ +
+ .00 +
+

@@ -42,6 +56,7 @@
Log In to bid on this Listing {% endif %} + {% endif %}

Comments ...

@@ -54,7 +69,7 @@ {% else %} {% for comment in Listing.comments.all %} - {{comment.user}} - {{comment.date_added}} + {{comment.user}} - {{comment.date_added}}
{{ comment.body }}
@@ -63,20 +78,25 @@ {% endif %} - {% if user.is_authenticated %} + {% if not Listing.closed%}
Add comment

- + {% csrf_token %} - +

+ {% elif not user.is_authenticated %} +
+
+ Log In to comment on this listing + {% else %}

- Log In to comment on this listing + The Listing is CLOSED for comments {% endif %} diff --git a/auctions/views.py b/auctions/views.py index 01934f9..a901427 100644 --- a/auctions/views.py +++ b/auctions/views.py @@ -164,6 +164,15 @@ def bid(request, title): "bids" : bid }) def close_bid(request,title): - pass + listing = AuctionListing.objects.get(title=title) + listing.closed = True + listing.save() + previous_url = request.POST.get('previous','/') + print(previous_url) + + + return HttpResponseRedirect(previous_url) + + diff --git a/db.sqlite3 b/db.sqlite3 index e8457ff..9c78f25 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ