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,21 +26,28 @@
<!--Change auctions_now, auction to like favorites, favorite-->
<div class="event-container">
{% if auctions_now %}
{% for auction in auctions_now %}
<div class="event">
{% comment %} <img src="http://via.placeholder.com/640x360" alt="">
{% 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>
</div>
{% endif %}
<div class="event-text">
<a href="{% url 'auctionid' auction.auctionid %}">
<h3>{{ auction.title }}</h3>
</a>
<p>{{ auction.info }}</p>
</div> {% endcomment %}
</div>
{% endfor %}
{% endfor %}
{% endfor %}
{% else %}
<h3> No Favorites.</h3>
<h3> No Favorites.</h3>
{% endif %}
</div>
</div>
......
......@@ -12,7 +12,10 @@
<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
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 %}
\ No newline at end of file
......@@ -10,7 +10,9 @@ class PlaceBidForm(forms.ModelForm):
class Meta:
model = AuctionBid
fields = ['amount', 'boodleuserid', 'auctionid']
widgets = {'auctionid': forms.HiddenInput(), 'boodleuserid': forms.HiddenInput()}
widgets = {'auctionid': forms.HiddenInput(),
'boodleuserid': forms.HiddenInput()
}
def clean(self):
super().clean()
......
......@@ -19,7 +19,10 @@ class Auction(models.Model):
class Meta:
managed = False
db_table = 'auction'
def __str__(self):
return f' {type(self.auctionid)}'
# return f'{type(self.title)} {type(self.auctionid)}'
class AuctionBid(models.Model):
bidno = models.AutoField(primary_key=True)
......@@ -32,8 +35,8 @@ class AuctionBid(models.Model):
managed = False
db_table = 'auctionbid'
def __str__(self):
return self.boodleuserid
# def __str__(self):
# return self.boodleuserid
class AuthGroup(models.Model):
......
......@@ -36,16 +36,15 @@ def auction(request,pk):
# Current auction ID
auction = Auction.objects.get(pk=pk)
# Item for auction
auction_item = auction.itemid
auction_item = auction.itemid # this is the itemfk thru auction
# Auction bids
auction_bids = AuctionBid.objects.filter(auctionid=pk).order_by('-bidtime')
highest_bid = auction_item.floorprice
highest_bid = auction_item.floorprice
# get boodle user ID
# userid = AuctionBid.objects.filter(userid=pk)
users = BoodleUser.objects.get(userid=3)
users = BoodleUser.objects.get(userid=1)
userid = users.userid
# getting the user name
#user_profile = users.displayname
# user_profile = users.displayname
if auction_bids:
highest_bid = auction_bids[0].amount
......@@ -60,7 +59,7 @@ def auction(request,pk):
# saves the bid by auctionid, amount, bidtime, boodleuserid
new_bid = AuctionBid(
amount=amount, bidtime=datetime.now(),
auctionid=auction, boodleuserid=userid)
auctionid=auction, boodleuserid=users)
new_bid.save()
return redirect(f"/auction/{pk}")
except:
......@@ -147,23 +146,36 @@ def startAuction(request):
def tempProfile(request): # temp view
#### 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 = {
'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)
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 = {
'displayname': current_user.displayname,
'username':current_user.username,
'bidsByUser' : bidsByUser,
'auctionsOfUser': auctionsOfUser,
'auctions': auctions,
}
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