Fixed views, made it accept bids for a specific user.

Modified forms.py and models.py
Added another user in tempprofile.html
Trying to get auctions to send to the profile of a specific user but it's not showing up in the carosel.
Co-authored-by: 's avatarpinkboheme <pinkboheme@users.noreply.github.com>
parent fed1c184
...@@ -26,19 +26,26 @@ ...@@ -26,19 +26,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 auctions_now %} {% if auctionsOfUser %}
{% for auction in auctions_now %} {% for id in auctionsOfUser %}
{% for aucid in auction %}
{% comment %} {% if id.auctionid == auctionsOfUser.auctionid %} {% endcomment %}
{% if id == aucid.auctionid %}
<div class="event"> <div class="event">
{% comment %} <img src="http://via.placeholder.com/640x360" alt=""> <img src="http://via.placeholder.com/640x360" alt="">
<div class="event-text"> <div class="event-text">
<a href="{% url 'auctionid' auction.auctionid %}"> <a href="{% url 'auctionid' id.auctionid %}">
<h3>{{ auction.title }}</h3> <h3>{{ id.title }}</h3>
</a> </a>
<p>{{ auction.info }}</p> <p>{{ id.auctionend }}</p>
</div> {% endcomment %} </div>
</div> </div>
{% endif %}
{% endfor %} {% endfor %}
{% endfor %}
{% else %} {% else %}
<h3> No Favorites.</h3> <h3> No Favorites.</h3>
{% endif %} {% endif %}
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
<h2>This is a temp page to access userid 1 (and not thru the navbar)</h2> <h2>This is a temp page to access userid 1 (and not thru the navbar)</h2>
<p>Remove this page once nav bar is personalized that it <p>Remove this page once nav bar is personalized that it
accesses the logged in user's profile</p> accesses the logged in user's profile</p>
<h1 text-align="center">Link to My Profile: <a href="{% url 'profileid' current_user.userid %}">{{ current_user.userid}}</a></h1>
<h1 text-align="center">Link to My Profile: <a href="{% url 'profileid' user_one.userid %}">{{ user_one.userid }}</a></h1>
<h1 text-align="center">Link to My OTHER Profile: <a href="{% url 'profileid' user_two.userid %}">{{user_two.userid}}</a></h1>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -10,7 +10,9 @@ class PlaceBidForm(forms.ModelForm): ...@@ -10,7 +10,9 @@ class PlaceBidForm(forms.ModelForm):
class Meta: class Meta:
model = AuctionBid model = AuctionBid
fields = ['amount', 'boodleuserid', 'auctionid'] fields = ['amount', 'boodleuserid', 'auctionid']
widgets = {'auctionid': forms.HiddenInput(), 'boodleuserid': forms.HiddenInput()} widgets = {'auctionid': forms.HiddenInput(),
'boodleuserid': forms.HiddenInput()
}
def clean(self): def clean(self):
super().clean() super().clean()
......
...@@ -20,6 +20,9 @@ class Auction(models.Model): ...@@ -20,6 +20,9 @@ class Auction(models.Model):
managed = False managed = False
db_table = 'auction' db_table = 'auction'
def __str__(self):
return f' {type(self.auctionid)}'
# return f'{type(self.title)} {type(self.auctionid)}'
class AuctionBid(models.Model): class AuctionBid(models.Model):
bidno = models.AutoField(primary_key=True) bidno = models.AutoField(primary_key=True)
...@@ -32,8 +35,8 @@ class AuctionBid(models.Model): ...@@ -32,8 +35,8 @@ class AuctionBid(models.Model):
managed = False managed = False
db_table = 'auctionbid' db_table = 'auctionbid'
def __str__(self): # def __str__(self):
return self.boodleuserid # return self.boodleuserid
class AuthGroup(models.Model): class AuthGroup(models.Model):
......
...@@ -36,16 +36,15 @@ def auction(request,pk): ...@@ -36,16 +36,15 @@ def auction(request,pk):
# Current auction ID # Current auction ID
auction = Auction.objects.get(pk=pk) auction = Auction.objects.get(pk=pk)
# Item for auction # Item for auction
auction_item = auction.itemid auction_item = auction.itemid # this is the itemfk thru auction
# Auction bids # Auction bids
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
# userid = AuctionBid.objects.filter(userid=pk) 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
if auction_bids: if auction_bids:
highest_bid = auction_bids[0].amount highest_bid = auction_bids[0].amount
...@@ -60,7 +59,7 @@ def auction(request,pk): ...@@ -60,7 +59,7 @@ def auction(request,pk):
# saves the bid by auctionid, amount, bidtime, boodleuserid # saves the bid by auctionid, amount, bidtime, boodleuserid
new_bid = AuctionBid( new_bid = AuctionBid(
amount=amount, bidtime=datetime.now(), amount=amount, bidtime=datetime.now(),
auctionid=auction, boodleuserid=userid) auctionid=auction, boodleuserid=users)
new_bid.save() new_bid.save()
return redirect(f"/auction/{pk}") return redirect(f"/auction/{pk}")
except: except:
...@@ -147,23 +146,36 @@ def startAuction(request): ...@@ -147,23 +146,36 @@ def startAuction(request):
def tempProfile(request): # temp view def tempProfile(request): # temp view
#### Access to store 1 [ edit accordingly when it becomes accessible thru a user ] #### #### Access to store 1 [ edit accordingly when it becomes accessible thru a user ] ####
current_user =BoodleUser.objects.get(userid=1) user_one =BoodleUser.objects.get(userid=1)
user_two = BoodleUser.objects.get(userid=3)
context = { context = {
'current_user':current_user #### used for navbar, access to user1 'user_one':user_one, #### used for navbar, access to user1
'user_two':user_two, #### used for navbar, access to user1
} }
return render(request, "boodlesite/templates/tempprofile.html", context) return render(request, "boodlesite/templates/tempprofile.html", context)
def profile(request, pk): def profile(request, pk):
# filter the favorites i think from auction tapos
# we need to add things like .add() and .remove()
# get the user's information
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
bidsByUser = AuctionBid.objects.filter(boodleuserid=1)
auctionsOfUser = Auction.objects.all().distinct('auctionid')
#💫auctionsOfUser = Auction.objects.all().distinct('auctionid')
# get existing auctions for user's bids
auctions = Auction.objects.all()
for auction in auctionsOfUser:
print(auction)
context = { context = {
'displayname': current_user.displayname, 'displayname': current_user.displayname,
'username':current_user.username, 'username':current_user.username,
'bidsByUser' : bidsByUser,
'auctionsOfUser': auctionsOfUser,
'auctions': auctions,
} }
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