Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Boodle
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martina Therese R. Reyes
Boodle
Commits
94336cf2
Commit
94336cf2
authored
Apr 29, 2022
by
Christine Dela Rosa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add purchase history to profile
Edit ongoing bid to display only ongoign auctions
parent
8bdf4784
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
8 deletions
+50
-8
profile.html
boodlesite/templates/profile.html
+21
-0
views.py
main/views.py
+29
-8
No files found.
boodlesite/templates/profile.html
View file @
94336cf2
...
...
@@ -39,11 +39,31 @@
</div>
</div>
<!-- Purchase History -->
<div>
<h2>
Purchase History
</h2>
{% if auctionsOfUser %}
{% for item in won_items %}
<div>
<h3>
{{ item.itemname }}
</h3>
<p
>
₱ {{item.sellprice}}
</p>
{% for wonauc in won_auctions %}
{% if wonauc.itemid == item %}
<h4>
Aution Ended at: {{ wonauc.auctionend }}
</h4>
{% endif %}
{% endfor %}
<br>
{% endfor %}
{% endif %}
</div>
</div>
<!--Change auctions_now, auction to like favorites, favorite-->
<h2>
Items {{displayname}} bid on
</h2>
<div
class=
"event-container"
>
{% if auctionsOfUser %}
{% for id in idsOfAuction %}
{% if id.auctionend > currentdate %}
<div
class=
"event"
>
<img
src=
"http://via.placeholder.com/640x360"
alt=
""
>
<div
class=
"event-text"
>
...
...
@@ -53,6 +73,7 @@
<p>
{{ id.auctionend }}
</p>
</div>
</div>
{% endif %}
{% endfor %}
{% else %}
...
...
main/views.py
View file @
94336cf2
...
...
@@ -3,6 +3,7 @@ from django.http import HttpResponseRedirect
from
django.http
import
HttpResponse
from
django.core.exceptions
import
ValidationError
from
django.utils
import
timezone
from
.models
import
*
from
.forms
import
*
...
...
@@ -243,6 +244,31 @@ def profile(request, pk):
# get existing auctions for user's bids
auctions
=
Auction
.
objects
.
all
()
### Purchase History ###
# Get auctionstart < currentdate auctions
current_date
=
datetime
.
now
()
won_itemids
=
[]
won_auctions
=
[]
for
aucid
in
idsOfAuction
:
tempAuction
=
Auction
.
objects
.
get
(
pk
=
aucid
.
auctionid
)
auctionend
=
tempAuction
.
auctionend
# finished auction, auctionend
if
auctionend
<
current_date
:
bids
=
AuctionBid
.
objects
.
filter
(
auctionid
=
aucid
)
.
order_by
(
'-bidtime'
)
highest_bidder
=
bids
[
0
]
.
boodleuserid
if
highest_bidder
.
userid
==
current_user
.
userid
:
itemid
=
aucid
.
itemid
itemid
.
sellprice
=
bids
[
0
]
.
amount
won_auctions
.
append
(
aucid
)
won_itemids
.
append
(
itemid
)
# 🔥Current Store, pk here is the storeid
current_user
=
BoodleUser
.
objects
.
get
(
pk
=
pk
)
form
=
CreateStoreForm
(
initial
=
{
'userid'
:
pk
})
...
...
@@ -261,14 +287,6 @@ def profile(request, pk):
return
redirect
(
'profileid'
,
pk
=
pk
)
# 🔥
# checks if userid exists in store
# if current_user.userid in Store.objects.get():
# if current_user:
# current_store = Store.objects.filter(userid=pk)
# # current_store = Store.objects.get(pk=pk)
# # if the current store exists, it will be the pk the
# else:
# current_store.storeid = None # if current store doesnt exist (no user)
context
=
{
'displayname'
:
current_user
.
displayname
,
...
...
@@ -279,6 +297,9 @@ def profile(request, pk):
'auctionsOfUser'
:
auctionsOfUser
,
'auctions'
:
auctions
,
'idsOfAuction'
:
idsOfAuction
,
'won_items'
:
won_itemids
,
'won_auctions'
:
won_auctions
,
'currentdate'
:
current_date
,
'createStoreForm'
:
form
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment