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