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
Show 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 @@
...
@@ -39,11 +39,31 @@
</div>
</div>
</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-->
<!--Change auctions_now, auction to like favorites, favorite-->
<h2>
Items {{displayname}} bid on
</h2>
<h2>
Items {{displayname}} bid on
</h2>
<div
class=
"event-container"
>
<div
class=
"event-container"
>
{% if auctionsOfUser %}
{% if auctionsOfUser %}
{% for id in idsOfAuction %}
{% for id in idsOfAuction %}
{% if id.auctionend > currentdate %}
<div
class=
"event"
>
<div
class=
"event"
>
<img
src=
"http://via.placeholder.com/640x360"
alt=
""
>
<img
src=
"http://via.placeholder.com/640x360"
alt=
""
>
<div
class=
"event-text"
>
<div
class=
"event-text"
>
...
@@ -53,6 +73,7 @@
...
@@ -53,6 +73,7 @@
<p>
{{ id.auctionend }}
</p>
<p>
{{ id.auctionend }}
</p>
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}
{% endfor %}
{% else %}
{% else %}
...
...
main/views.py
View file @
94336cf2
...
@@ -3,6 +3,7 @@ from django.http import HttpResponseRedirect
...
@@ -3,6 +3,7 @@ from django.http import HttpResponseRedirect
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django.utils
import
timezone
from
.models
import
*
from
.models
import
*
from
.forms
import
*
from
.forms
import
*
...
@@ -243,6 +244,31 @@ def profile(request, pk):
...
@@ -243,6 +244,31 @@ def profile(request, pk):
# get existing auctions for user's bids
# get existing auctions for user's bids
auctions
=
Auction
.
objects
.
all
()
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 Store, pk here is the storeid
current_user
=
BoodleUser
.
objects
.
get
(
pk
=
pk
)
current_user
=
BoodleUser
.
objects
.
get
(
pk
=
pk
)
form
=
CreateStoreForm
(
initial
=
{
'userid'
:
pk
})
form
=
CreateStoreForm
(
initial
=
{
'userid'
:
pk
})
...
@@ -261,14 +287,6 @@ def profile(request, pk):
...
@@ -261,14 +287,6 @@ def profile(request, pk):
return
redirect
(
'profileid'
,
pk
=
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
=
{
context
=
{
'displayname'
:
current_user
.
displayname
,
'displayname'
:
current_user
.
displayname
,
...
@@ -279,6 +297,9 @@ def profile(request, pk):
...
@@ -279,6 +297,9 @@ def profile(request, pk):
'auctionsOfUser'
:
auctionsOfUser
,
'auctionsOfUser'
:
auctionsOfUser
,
'auctions'
:
auctions
,
'auctions'
:
auctions
,
'idsOfAuction'
:
idsOfAuction
,
'idsOfAuction'
:
idsOfAuction
,
'won_items'
:
won_itemids
,
'won_auctions'
:
won_auctions
,
'currentdate'
:
current_date
,
'createStoreForm'
:
form
'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