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
ce44a995
Commit
ce44a995
authored
Apr 07, 2022
by
Christine Dela Rosa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create StartAuctionForm, Display auctions on homepage
parent
29a17ac0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
9 deletions
+52
-9
startauction.html
boodlesite/templates/startauction.html
+8
-3
store.html
boodlesite/templates/store.html
+1
-1
forms.py
main/forms.py
+22
-1
models.py
main/models.py
+3
-0
urls.py
main/urls.py
+1
-0
views.py
main/views.py
+17
-4
No files found.
boodlesite/templates/startauction.html
View file @
ce44a995
...
...
@@ -9,11 +9,18 @@
{% block content %}
<div
class=
"container"
><button
type=
"button"
>
Save Auction
</button>
<div
class=
"container"
>
<form
action=
""
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"submit"
name=
"savesauction"
>
Save Auction
</button>
</form>
</div>
<!-- Form fields:
[Auction Title]
[Auction Description]
Drop down: [Select time for Auction]
Set Auction timer:
Start:
...
...
@@ -22,6 +29,4 @@ End:
Drop down: [Month] [Day] [Year] Time: [Hour] : [Minute]
-->
{% endblock %}
\ No newline at end of file
boodlesite/templates/store.html
View file @
ce44a995
...
...
@@ -68,7 +68,7 @@
<div
class=
"store-btns-container"
>
<button
type=
"button"
><a
href=
"
/startauction
"
>
Start Auction
</a></button>
<button
type=
"button"
><a
href=
"
{% url 'startauctionid' current_store.storeid %}
"
>
Start Auction
</a></button>
<button
type=
"button"
><a
href=
"{% url 'additemid' current_store.storeid %}"
>
Add Item
</a></button>
</div>
...
...
main/forms.py
View file @
ce44a995
from
datetime
import
datetime
from
django
import
forms
from
django.forms
import
(
ModelForm
,
TextInput
,
Textarea
,
widgets
)
...
...
@@ -40,4 +41,24 @@ class AddItemForm(forms.ModelForm):
'itemname'
:
_
(
'Item Name'
),
'itemspecs'
:
_
(
'Item Description'
),
'floorprice'
:
_
(
'Floor Price'
)
}
\ No newline at end of file
}
class
StartAuctionForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Auction
fields
=
'__all__'
labels
=
{
'title'
:
_
(
'Auction Title'
),
'info'
:
_
(
'Auction Description'
),
'auctionstart'
:
_
(
'Starting time'
),
'auctionend'
:
_
(
'Closing time'
),
'itemid'
:
_
(
'Item up for auction'
)
}
# datetime_format = ['%Y-%m-%d %H:%M']
# widgets = { 'auctionstart' : forms.DateTimeInput(input_formats=['%Y-%m-%d %H:%M']), 'auctionend' : forms.DateTimeInput(input_formats=['%Y-%m-%d %H:%M'])}
# vv fix later, is missing time widget
# widgets = { 'auctionstart' : forms.SelectDateWidget, 'auctionend':forms.SelectDateWidget}
# 'itemid': forms.HiddenInput()}
\ No newline at end of file
main/models.py
View file @
ce44a995
...
...
@@ -157,6 +157,9 @@ class Item(models.Model):
managed
=
False
db_table
=
'item'
def
__str__
(
self
):
return
'
%
s'
%
(
self
.
itemname
)
class
Store
(
models
.
Model
):
storeid
=
models
.
AutoField
(
primary_key
=
True
)
...
...
main/urls.py
View file @
ce44a995
...
...
@@ -12,5 +12,6 @@ urlpatterns = [
path
(
'additem'
,
addItem
,
name
=
'additem'
),
path
(
'additem/<int:pk>'
,
addItem
,
name
=
'additemid'
),
path
(
'startauction'
,
startAuction
,
name
=
'startauction'
),
path
(
'startauction/<int:pk>'
,
startAuction
,
name
=
'startauctionid'
),
]
\ No newline at end of file
main/views.py
View file @
ce44a995
...
...
@@ -125,13 +125,26 @@ def addItem(request, pk):
return
render
(
request
,
"boodlesite/templates/additem.html"
,
context
)
def
startAuction
(
request
):
def
startAuction
(
request
,
pk
):
# pk is store id
current_store
=
Store
.
objects
.
get
(
pk
=
pk
)
# get items under this store
store_items
=
Item
.
objects
.
filter
(
storeid
=
pk
)
form
=
StartAuctionForm
(
initial
=
{
'storeid'
:
current_store
})
if
request
.
method
==
'POST'
:
form
=
StartAuctionForm
(
request
.
POST
,
initial
=
{
'storeid'
:
current_store
})
if
form
.
is_valid
():
form
.
save
()
return
redirect
(
'storeid'
,
pk
=
pk
)
#### Access to store 1 [ edit accordingly when it becomes accessible thru a user ] ####
current_store
=
Store
.
objects
.
get
(
storeid
=
1
)
context
=
{
'current_store'
:
current_store
'current_store'
:
current_store
,
'store_items'
:
store_items
,
'form'
:
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