Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
GrabGrub
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
Matthew Dominic M. Dizon
GrabGrub
Commits
aa6e6b06
Commit
aa6e6b06
authored
May 27, 2021
by
Matthew Dizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add order functionality
parent
79898797
Pipeline
#1925
canceled with stages
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
2 deletions
+87
-2
add_order.html
GrabGrub/Kiosk/templates/Kiosk/add_order.html
+51
-0
home.html
GrabGrub/Kiosk/templates/Kiosk/home.html
+1
-0
update_order.html
GrabGrub/Kiosk/templates/Kiosk/update_order.html
+2
-2
urls.py
GrabGrub/Kiosk/urls.py
+1
-0
views.py
GrabGrub/Kiosk/views.py
+32
-0
db.sqlite3
GrabGrub/db.sqlite3
+0
-0
No files found.
GrabGrub/Kiosk/templates/Kiosk/add_order.html
0 → 100644
View file @
aa6e6b06
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block content %}
<div
class=
"card w-75"
>
<div
class=
"card-header"
>
Enter Order Details:
</div>
<form
method=
"POST"
action=
"{% url 'add_order' %}"
>
{% csrf_token %}
<div
class=
"form-group"
>
<label
for=
"name"
>
Food:
</label>
<select
name=
"food"
class=
"form-select"
style=
"max-width: 200px; margin-right: 75px;"
required
>
{% for food in foods %}
<option
value=
"{{food.id}}"
>
{{food.name}}
</option>
{% endfor %}
</select>
</div>
<div
class=
"form-group"
>
<label
for=
"name"
>
Quantity:
</label>
<input
type=
"number"
class=
"form-control"
id=
"qty"
name=
"qty"
value=
"{{order.qty}}"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"name"
>
Date of Order:
</label>
<input
type=
"date"
class=
"form-control"
id=
"date"
name=
"date"
value=
"{{order.ordered_at}}"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"name"
>
Customer:
</label>
<select
name=
"customer"
class=
"form-select"
style=
"max-width: 200px; margin-right: 75px;"
required
>
{% for customer in customers %}
<option
value=
"{{customer.id}}"
>
{{customer.name}}
</option>
{% endfor %}
</select>
</div>
<div
class=
"form-group"
>
<label
for=
"name"
>
Mode of Payment:
</label>
<select
name=
"payment_mode"
class=
"form-select"
style=
"max-width: 200px; margin-right: 75px;"
required
>
<option
value=
"Cash"
>
Cash
</option>
<option
value=
"Card"
>
Card
</option>
</select>
</div>
<a
href=
"{% url 'add_order' %}"
><button
type=
"submit"
class=
"mt-3 btn btn-primary"
>
Add Order
</button></a>
</form>
</div>
{% endblock %}
GrabGrub/Kiosk/templates/Kiosk/home.html
View file @
aa6e6b06
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
<div
class=
"container"
>
<div
class=
"container"
>
<h1
class=
"jumbotron-heading"
>
Orders
</h1>
<h1
class=
"jumbotron-heading"
>
Orders
</h1>
<p>
A table of all orders
</p>
<p>
A table of all orders
</p>
<a
href=
"{% url 'add_order' %}"
><button
class=
"btn btn-dark"
>
Add Order
</button></a>
</div>
</div>
</section>
</section>
...
...
GrabGrub/Kiosk/templates/Kiosk/update_order.html
View file @
aa6e6b06
...
@@ -16,12 +16,12 @@
...
@@ -16,12 +16,12 @@
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"name"
>
Quantity:
</label>
<label
for=
"name"
>
Quantity:
</label>
<input
type=
"
text
"
class=
"form-control"
id=
"qty"
name=
"qty"
value=
"{{order.qty}}"
required
>
<input
type=
"
number
"
class=
"form-control"
id=
"qty"
name=
"qty"
value=
"{{order.qty}}"
required
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"name"
>
Date of Order:
</label>
<label
for=
"name"
>
Date of Order:
</label>
<input
type=
"
text
"
class=
"form-control"
id=
"date"
name=
"date"
value=
"{{order.ordered_at}}"
disabled
>
<input
type=
"
date
"
class=
"form-control"
id=
"date"
name=
"date"
value=
"{{order.ordered_at}}"
disabled
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
...
GrabGrub/Kiosk/urls.py
View file @
aa6e6b06
...
@@ -11,6 +11,7 @@ urlpatterns = [
...
@@ -11,6 +11,7 @@ urlpatterns = [
path
(
'home'
,
views
.
home
,
name
=
"home"
),
path
(
'home'
,
views
.
home
,
name
=
"home"
),
path
(
'view_order_details/<int:pk>'
,
views
.
view_order_details
,
name
=
"view_order_details"
),
path
(
'view_order_details/<int:pk>'
,
views
.
view_order_details
,
name
=
"view_order_details"
),
path
(
'update_order/<int:pk>'
,
views
.
update_order
,
name
=
"update_order"
),
path
(
'update_order/<int:pk>'
,
views
.
update_order
,
name
=
"update_order"
),
path
(
'add_order'
,
views
.
add_order
,
name
=
"add_order"
),
# Path for Food Model
# Path for Food Model
path
(
'foods'
,
views
.
view_foods
,
name
=
"view_foods"
),
path
(
'foods'
,
views
.
view_foods
,
name
=
"view_foods"
),
path
(
'view_food_details/<int:pk>'
,
views
.
view_food_details
,
name
=
"view_food_details"
),
path
(
'view_food_details/<int:pk>'
,
views
.
view_food_details
,
name
=
"view_food_details"
),
...
...
GrabGrub/Kiosk/views.py
View file @
aa6e6b06
...
@@ -75,6 +75,38 @@ def update_order(request, pk):
...
@@ -75,6 +75,38 @@ def update_order(request, pk):
context
=
{
"order"
:
order
}
context
=
{
"order"
:
order
}
return
render
(
request
,
'Kiosk/update_order.html'
,
context
)
return
render
(
request
,
'Kiosk/update_order.html'
,
context
)
def
add_order
(
request
):
food_objects
=
Food
.
objects
.
all
()
customer_objects
=
Customer
.
objects
.
all
()
context
=
{
"foods"
:
food_objects
,
"customers"
:
customer_objects
}
if
(
request
.
method
==
"POST"
):
qty
=
request
.
POST
.
get
(
'qty'
)
payment_mode
=
request
.
POST
.
get
(
'payment_mode'
)
food
=
request
.
POST
.
get
(
'food'
)
date
=
request
.
POST
.
get
(
'date'
)
customer
=
request
.
POST
.
get
(
'customer'
)
try
:
Order
.
objects
.
create
(
food
=
Food
.
objects
.
get
(
id
=
food
),
qty
=
qty
,
ordered_at
=
date
,
cust_order
=
Customer
.
objects
.
get
(
id
=
customer
),
payment_mode
=
payment_mode
)
return
redirect
(
'home'
)
except
Exception
as
e
:
message
=
e
print
(
message
)
return
render
(
request
,
'Kiosk/add_order.html'
,
context
)
else
:
return
render
(
request
,
'Kiosk/add_order.html'
,
context
)
### Views for Food Model
### Views for Food Model
def
view_foods
(
request
):
def
view_foods
(
request
):
foods
=
Food
.
objects
.
all
()
foods
=
Food
.
objects
.
all
()
...
...
GrabGrub/db.sqlite3
View file @
aa6e6b06
No preview for this file type
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