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
d4698798
Commit
d4698798
authored
Apr 06, 2022
by
Martina Therese R. Reyes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Imitating Place Bid feature for add to favorites.
Made a modal and forms.py is a work in progress.
parent
22d9e803
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
17 deletions
+55
-17
auction.html
boodlesite/templates/auction.html
+31
-4
forms.py
main/forms.py
+7
-1
models.py
main/models.py
+2
-2
views.py
main/views.py
+15
-10
No files found.
boodlesite/templates/auction.html
View file @
d4698798
...
@@ -67,11 +67,38 @@
...
@@ -67,11 +67,38 @@
<button
type=
"button"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#placeBidModal"
<button
type=
"button"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#placeBidModal"
data-whatever=
"@mdo"
>
Place Bid
</button>
data-whatever=
"@mdo"
>
Place Bid
</button>
<button
type=
"button"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#addToFavoritesModal"
data-whatever=
"@mdo"
>
Add to favorites
</button>
<form
method=
"POST"
action=
""
>
<!-- MODAL FOR ADD TO FAVORITES-->
<div
class=
"modal fade"
id=
"addToFavoritesModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"exampleModalLabel"
>
Confirm Add to Favorites
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
>
<form
action=
""
method=
"POST"
>
<div
class=
"form-group"
>
{% csrf_token %}
{% csrf_token %}
<input
type=
"hidden"
name=
"supporttype"
/>
{{ addtofavs_form }}
<button
type=
"button"
class=
"btn btn-dark"
><input
type=
"submit"
value=
"Add to My Favorites"
/>
</button>
</div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Cancel
</button>
<button
type=
"submit"
class=
"btn btn-secondary"
name=
"Submit"
>
Submit
</button>
</div>
</form>
</div>
</div>
</div>
<!-- MODAL FOR BIDDING -->
<!-- MODAL FOR BIDDING -->
<div
class=
"modal fade"
id=
"placeBidModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalLabel"
<div
class=
"modal fade"
id=
"placeBidModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalLabel"
...
...
main/forms.py
View file @
d4698798
...
@@ -41,3 +41,9 @@ class AddItemForm(forms.ModelForm):
...
@@ -41,3 +41,9 @@ class AddItemForm(forms.ModelForm):
'itemspecs'
:
_
(
'Item Description'
),
'itemspecs'
:
_
(
'Item Description'
),
'floorprice'
:
_
(
'Floor Price'
)
'floorprice'
:
_
(
'Floor Price'
)
}
}
class
AddToFavoritesForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
UserFavorites
fields
=
[
'userid'
,
'auctionid'
]
widgets
=
{
'auctionid'
:
forms
.
HiddenInput
()}
\ No newline at end of file
main/models.py
View file @
d4698798
...
@@ -103,7 +103,6 @@ class BoodleUser(models.Model):
...
@@ -103,7 +103,6 @@ class BoodleUser(models.Model):
displayname
=
models
.
CharField
(
max_length
=
255
)
displayname
=
models
.
CharField
(
max_length
=
255
)
pword
=
models
.
CharField
(
max_length
=
255
)
pword
=
models
.
CharField
(
max_length
=
255
)
username
=
models
.
CharField
(
max_length
=
255
)
username
=
models
.
CharField
(
max_length
=
255
)
favorites
=
models
.
ManyToManyField
(
Auction
,
related_name
=
'user_favorites'
,
null
=
True
,
blank
=
True
)
class
Meta
:
class
Meta
:
managed
=
False
managed
=
False
...
@@ -177,7 +176,8 @@ class Store(models.Model):
...
@@ -177,7 +176,8 @@ class Store(models.Model):
db_table
=
'store'
db_table
=
'store'
class
Userfavorites
(
models
.
Model
):
class
UserFavorites
(
models
.
Model
):
favid
=
models
.
AutoField
(
primary_key
=
True
)
userid
=
models
.
ForeignKey
(
BoodleUser
,
models
.
DO_NOTHING
,
db_column
=
'userid'
)
userid
=
models
.
ForeignKey
(
BoodleUser
,
models
.
DO_NOTHING
,
db_column
=
'userid'
)
auctionid
=
models
.
ForeignKey
(
Auction
,
models
.
DO_NOTHING
,
db_column
=
'auctionid'
)
auctionid
=
models
.
ForeignKey
(
Auction
,
models
.
DO_NOTHING
,
db_column
=
'auctionid'
)
...
...
main/views.py
View file @
d4698798
...
@@ -45,6 +45,7 @@ def auction(request, pk):
...
@@ -45,6 +45,7 @@ def auction(request, pk):
if
auction_bids
:
if
auction_bids
:
highest_bid
=
auction_bids
[
0
]
.
amount
highest_bid
=
auction_bids
[
0
]
.
amount
# PLACE BID FORM
form
=
PlaceBidForm
(
initial
=
{
'auctionid'
:
auction
})
form
=
PlaceBidForm
(
initial
=
{
'auctionid'
:
auction
})
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
PlaceBidForm
(
request
.
POST
,
initial
=
{
'auctionid'
:
auction
})
form
=
PlaceBidForm
(
request
.
POST
,
initial
=
{
'auctionid'
:
auction
})
...
@@ -57,6 +58,19 @@ def auction(request, pk):
...
@@ -57,6 +58,19 @@ def auction(request, pk):
except
:
except
:
pass
pass
# ADD TO FAVORITES FORM
addtofavs_form
=
AddToFavoritesForm
()
if
request
.
method
==
'POST'
:
addtofavs_form
=
AddToFavoritesForm
(
request
.
POST
)
# if addtofavs_form.is_valid():
# try:
# amount = addtofavs_form.cleaned_data['amount']
# new_bid = AuctionBid(amount=amount,bidtime=datetime.now(),auctionid=auction)
# new_bid.save()
# return redirect(f"/auction/{pk}")
# except:
# pass
context
=
{
context
=
{
'item_name'
:
auction_item
.
itemname
,
'item_name'
:
auction_item
.
itemname
,
...
@@ -66,6 +80,7 @@ def auction(request, pk):
...
@@ -66,6 +80,7 @@ def auction(request, pk):
'highest_bid'
:
highest_bid
,
'highest_bid'
:
highest_bid
,
'auction_end'
:
auction
.
auctionend
,
'auction_end'
:
auction
.
auctionend
,
'form'
:
form
,
'form'
:
form
,
'addtofavs_form'
:
addtofavs_form
,
}
}
if
auction
.
auctionend
<
datetime
.
now
():
if
auction
.
auctionend
<
datetime
.
now
():
...
@@ -159,13 +174,3 @@ def profile(request, pk):
...
@@ -159,13 +174,3 @@ def profile(request, pk):
}
}
return
render
(
request
,
"boodlesite/templates/profile.html"
,
context
)
return
render
(
request
,
"boodlesite/templates/profile.html"
,
context
)
def
favorites
(
request
,
pk
):
if
request
.
method
==
'POST'
:
favorite
=
Auction
.
objects
.
get
(
pk
=
pk
)
# user = request.user
current_user
=
BoodleUser
.
objects
.
get
(
pk
=
pk
)
current_user
.
favorites
.
add
(
favorite
)
print
(
"Favorited!"
)
#messages.add_message(request, messages.INFO, 'Deal Favorited.')
return
redirect
(
f
"/auction/{pk}"
)
\ No newline at end of file
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