Made the auctions appear for specific users.

When a user bids on something, it appears on their profile --
provided that they are the user logged in.
Co-authored-by: 's avatarpinkboheme <pinkboheme@users.noreply.github.com>
Co-authored-by: 's avatarChristine <cdeeerrr@users.noreply.github.com>
parent ad5e2f3c
......@@ -27,28 +27,26 @@
<!--Change auctions_now, auction to like favorites, favorite-->
<div class="event-container">
{% if auctionsOfUser %}
{% for id in auctionsOfUser %}
{% for aucid in auction %}
{% comment %} {% if id.auctionid == auctionsOfUser.auctionid %} {% endcomment %}
{% if id == aucid.auctionid %}
<div class="event">
<img src="http://via.placeholder.com/640x360" alt="">
<div class="event-text">
<a href="{% url 'auctionid' id.auctionid %}">
<h3>{{ id.title }}</h3>
</a>
<p>{{ id.auctionend }}</p>
</div>
{% for id in idsOfAuction %}
<div class="event">
<img src="http://via.placeholder.com/640x360" alt="">
<div class="event-text">
<a href="{% url 'auctionid' id.auctionid %}">
<h3>{{ id.title }}</h3>
</a>
<p>{{ id.auctionend }}</p>
</div>
<input type="submit" value="remove auction">
<!-- if button is clidked -->
<!-- id rmeove from ids of auctions -->
</div>
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% else %}
<h3> No Favorites.</h3>
{% endif %}
</div>
</div>
{% endblock %}
......@@ -21,7 +21,7 @@ class Auction(models.Model):
db_table = 'auction'
def __str__(self):
return f' {type(self.auctionid)}'
return f' {self.auctionid}'
# return f'{type(self.title)} {type(self.auctionid)}'
class AuctionBid(models.Model):
......
......@@ -41,7 +41,7 @@ def auction(request,pk):
auction_bids = AuctionBid.objects.filter(auctionid=pk).order_by('-bidtime')
highest_bid = auction_item.floorprice
# get boodle user ID
users = BoodleUser.objects.get(userid=1)
users = BoodleUser.objects.get(userid=3)
userid = users.userid
# getting the user name
# user_profile = users.displayname
......@@ -160,15 +160,32 @@ def profile(request, pk):
current_user = BoodleUser.objects.get(pk=pk)
#auction bid user id = 3 --> bids user made --> know auctions g
bidsByUser = AuctionBid.objects.filter(boodleuserid=1)
auctionsOfUser = Auction.objects.all().distinct('auctionid')
bidsByUser = AuctionBid.objects.filter(boodleuserid=3).distinct('auctionid')
auctionsOfUser = Auction.objects.all().distinct('auctionid')
# for auction in auctionsOfUser:
# print(auction)
# print(auction.title)
# print(auction.auctionid)
#Is of auctions (FK) in AuctionBid objects
idsOfAuction = []
for bid in bidsByUser:
for auction in auctionsOfUser:
if bid.auctionid == auction:
idsOfAuction.append(bid.auctionid)
# print(auction.title)
# print(bid.auctionid)
# print("===============") #divider between auctions :3
print("These are the distinct auction IDs: ", idsOfAuction)
#💫auctionsOfUser = Auction.objects.all().distinct('auctionid')
# get existing auctions for user's bids
auctions = Auction.objects.all()
for auction in auctionsOfUser:
print(auction)
# for auction in auctionsOfUser:
# print(auction)
context = {
'displayname': current_user.displayname,
......@@ -176,6 +193,7 @@ def profile(request, pk):
'bidsByUser' : bidsByUser,
'auctionsOfUser': auctionsOfUser,
'auctions': auctions,
'idsOfAuction': idsOfAuction,
}
return render(request, "boodlesite/templates/profile.html", context)
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