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
Hide 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
...
...
@@ -66,12 +66,39 @@
<button
type=
"button"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#placeBidModal"
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>
<!-- 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>
<form
method=
"POST"
action=
""
>
{% csrf_token %}
<input
type=
"hidden"
name=
"supporttype"
/>
<button
type=
"button"
class=
"btn btn-dark"
><input
type=
"submit"
value=
"Add to My Favorites"
/>
</button>
<div
class=
"modal-body"
>
<form
action=
""
method=
"POST"
>
<div
class=
"form-group"
>
{% csrf_token %}
{{ addtofavs_form }}
</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 -->
<div
class=
"modal fade"
id=
"placeBidModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalLabel"
...
...
main/forms.py
View file @
d4698798
...
...
@@ -40,4 +40,10 @@ class AddItemForm(forms.ModelForm):
'itemname'
:
_
(
'Item Name'
),
'itemspecs'
:
_
(
'Item Description'
),
'floorprice'
:
_
(
'Floor Price'
)
}
\ No newline at end of file
}
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):
displayname
=
models
.
CharField
(
max_length
=
255
)
pword
=
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
:
managed
=
False
...
...
@@ -177,7 +176,8 @@ class Store(models.Model):
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'
)
auctionid
=
models
.
ForeignKey
(
Auction
,
models
.
DO_NOTHING
,
db_column
=
'auctionid'
)
...
...
main/views.py
View file @
d4698798
...
...
@@ -45,6 +45,7 @@ def auction(request, pk):
if
auction_bids
:
highest_bid
=
auction_bids
[
0
]
.
amount
# PLACE BID FORM
form
=
PlaceBidForm
(
initial
=
{
'auctionid'
:
auction
})
if
request
.
method
==
'POST'
:
form
=
PlaceBidForm
(
request
.
POST
,
initial
=
{
'auctionid'
:
auction
})
...
...
@@ -56,6 +57,19 @@ def auction(request, pk):
return
redirect
(
f
"/auction/{pk}"
)
except
:
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
=
{
...
...
@@ -66,6 +80,7 @@ def auction(request, pk):
'highest_bid'
:
highest_bid
,
'auction_end'
:
auction
.
auctionend
,
'form'
:
form
,
'addtofavs_form'
:
addtofavs_form
,
}
if
auction
.
auctionend
<
datetime
.
now
():
...
...
@@ -159,13 +174,3 @@ def profile(request, pk):
}
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