From 91a7d90d53c395b0a93435726d803f8ae308c3ae Mon Sep 17 00:00:00 2001 From: Juan David Sandoval Salvador Date: Fri, 12 Sep 2025 17:06:01 -0500 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=90=9B=20fix:=20update=20URL=20naming?= =?UTF-8?q?=20for=20auction=20creation=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auctions/templates/auctions/components/footer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auctions/templates/auctions/components/footer.html b/auctions/templates/auctions/components/footer.html index 5c053dd..d3667ac 100644 --- a/auctions/templates/auctions/components/footer.html +++ b/auctions/templates/auctions/components/footer.html @@ -42,7 +42,7 @@
  • - + Create Listing From 0d05b8552c1dec8be36a43816c255c8790257ee9 Mon Sep 17 00:00:00 2001 From: Juan David Sandoval Salvador Date: Fri, 12 Sep 2025 17:06:58 -0500 Subject: [PATCH 2/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20refactor:=20update?= =?UTF-8?q?=20auction=20creation=20URL=20references=20to=20'new=5Fauction'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auctions/templates/auctions/categories.html | 2 +- auctions/templates/auctions/index.html | 4 ++-- auctions/templates/auctions/newAuctions.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auctions/templates/auctions/categories.html b/auctions/templates/auctions/categories.html index 5ba6714..7ec7467 100644 --- a/auctions/templates/auctions/categories.html +++ b/auctions/templates/auctions/categories.html @@ -76,7 +76,7 @@

    No listings found

    {{ selected_category|default:"No" }} items are currently available

    {% if user.is_authenticated %} diff --git a/auctions/templates/auctions/index.html b/auctions/templates/auctions/index.html index f7a06ce..885b0b7 100644 --- a/auctions/templates/auctions/index.html +++ b/auctions/templates/auctions/index.html @@ -14,7 +14,7 @@

    {% if user.is_authenticated %} @@ -78,7 +78,7 @@

    No active listings at the moment

    Be the first to create an auction and start earning!

    {% if user.is_authenticated %} - + Create New Auction {% else %} diff --git a/auctions/templates/auctions/newAuctions.html b/auctions/templates/auctions/newAuctions.html index 73b810f..0ff5f8d 100644 --- a/auctions/templates/auctions/newAuctions.html +++ b/auctions/templates/auctions/newAuctions.html @@ -13,7 +13,7 @@

    Create New Auction

    -
    + {% csrf_token %}
    From 7ce1c483eca4abb9337384a4361a93e2beba7631 Mon Sep 17 00:00:00 2001 From: Juan David Sandoval Salvador Date: Fri, 12 Sep 2025 19:22:42 -0500 Subject: [PATCH 3/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20refactor:=20improve?= =?UTF-8?q?=20variable=20naming=20and=20streamline=20watchlist=20functiona?= =?UTF-8?q?lity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auctions/views.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/auctions/views.py b/auctions/views.py index 70341fe..6df5e9a 100644 --- a/auctions/views.py +++ b/auctions/views.py @@ -79,9 +79,9 @@ def new_auctions(request): form = ListingForm(request.POST) if form.is_valid(): # Set the logged-in user - listing = form.save(commit=False) # Don't save yet - listing.user = request.user # Set the user - listing.save() # Now save the Listing} + new_listing = form.save(commit=False) # Don't save yet + new_listing.user = request.user # Set the user + new_listing.save() # Now save the Listing messages.success(request, "Your listing has been created.") return redirect("index") messages.error(request, "There was an error with created your listing.") @@ -112,7 +112,7 @@ def listing(request, listing_id): @login_required def bid(request, listing_id): auction = get_object_or_404(Listing, pk=listing_id) - comment_auction = auction.comments.all().count() + bid_count = auction.bids.count() if request.method == "POST": bid_form = BidForm(request.POST) if bid_form.is_valid(): @@ -122,7 +122,7 @@ def bid(request, listing_id): messages.success(request, "Your bid has been placed successfully.") messages.info( request, - f"({comment_auction}) bid(s) so far. Your bid is the current bid.", + f"({bid_count + 1}) bid(s) so far. Your bid is the current bid.", ) return redirect("listing", listing_id=listing_id) except ValidationError as e: @@ -143,15 +143,16 @@ def bid(request, listing_id): def watchlist(request, listing_id): user = request.user if request.method == "POST": - listings_in_watchlist = Watchlist.objects.filter( - user=user, listing__id=listing_id - ) - if listings_in_watchlist.exists(): - listings_in_watchlist.update(active=True) - return HttpResponseRedirect(reverse("watchlist", args=[user.id])) current_listing = Listing.objects.get(pk=listing_id) - Watchlist.objects.create(user=user, listing=current_listing, active=True) - return HttpResponseRedirect(reverse("watchlist", args=[user.id])) + watchlist_item, created = Watchlist.objects.get_or_create( + user=user, listing=current_listing + ) + if created: + watchlist_item.active = True + else: + watchlist_item.active = not watchlist_item.active + watchlist_item.save() + return HttpResponseRedirect(reverse("listing", args=[listing_id])) listings_in_watchlist = Listing.objects.filter( watchlist__user=user, watchlist__active=True ).order_by("-created") @@ -171,18 +172,18 @@ def watchlist_remove(request, listing_id): def close_auction(request, listing_id): - listing = get_object_or_404(Listing, id=listing_id) + auction_listing = get_object_or_404(Listing, id=listing_id) - if request.user != listing.user: + if request.user != auction_listing.user: messages.error(request, "You are not authorized to close this auction.") return redirect("listing", listing_id=listing_id) - highest_bid = listing.bids.order_by("-amount").first() + highest_bid = auction_listing.bids.order_by("-amount").first() if highest_bid: - listing.winner = highest_bid.user + auction_listing.winner = highest_bid.user else: messages.warning(request, "No bids were placed on this listing.") - listing.active = False - listing.save() + auction_listing.active = False + auction_listing.save() messages.success(request, "The auction has been closed.") return redirect("listing", listing_id=listing_id) From 67efae3623db9d20c1fdc91ee59a32072c68b8a0 Mon Sep 17 00:00:00 2001 From: Juan David Sandoval Salvador Date: Fri, 12 Sep 2025 19:22:53 -0500 Subject: [PATCH 4/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20refactor:=20update?= =?UTF-8?q?=20watchlist=20logic=20to=20use=20filtered=20active=20listings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auctions/templates/auctions/auction.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auctions/templates/auctions/auction.html b/auctions/templates/auctions/auction.html index b1ffc5f..feabc76 100644 --- a/auctions/templates/auctions/auction.html +++ b/auctions/templates/auctions/auction.html @@ -75,11 +75,11 @@

    {{ listing.title }}

    {% csrf_token %}