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
645ee339
Commit
645ee339
authored
May 27, 2021
by
Matthew Dizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
messages with CRUD functionality for order
parent
6c8c6912
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
8 deletions
+34
-8
base.html
GrabGrub/Kiosk/templates/Kiosk/base.html
+5
-0
home.html
GrabGrub/Kiosk/templates/Kiosk/home.html
+4
-0
view_order_details.html
GrabGrub/Kiosk/templates/Kiosk/view_order_details.html
+3
-0
views.py
GrabGrub/Kiosk/views.py
+22
-8
No files found.
GrabGrub/Kiosk/templates/Kiosk/base.html
View file @
645ee339
...
...
@@ -39,6 +39,11 @@
.active
{
color
:
#23272B
;
}
label
{
color
:
#8AB4F8
;
font-weight
:
bold
;
}
</style>
<body>
...
...
GrabGrub/Kiosk/templates/Kiosk/home.html
View file @
645ee339
...
...
@@ -10,6 +10,10 @@
</div>
</section>
{% if message %}
<p
class=
"mt-3 alert alert-success"
>
{{message}}
</p>
{% endif %}
<div
class=
"col-12"
>
<table
class=
"table table-striped"
>
<thead>
...
...
GrabGrub/Kiosk/templates/Kiosk/view_order_details.html
View file @
645ee339
...
...
@@ -18,4 +18,7 @@
<a
href=
"{% url 'update_order' order.pk %}"
><button
class=
"btn btn-primary"
>
Update Order
</button></a>
<a
href=
"{% url 'delete_order' order.pk %}"
><button
class=
"btn btn-danger my-4"
>
Delete Order
</button></a>
<a
href=
"{% url 'home' %}"
><button
class=
"btn btn-secondary"
>
Back
</button></a>
{% if message %}
<p
class=
"mt-3 alert alert-success"
style=
"width: 75%"
>
{{message}}
</p>
{% endif %}
{% endblock %}
\ No newline at end of file
GrabGrub/Kiosk/views.py
View file @
645ee339
...
...
@@ -64,7 +64,10 @@ def home(request):
def
view_order_details
(
request
,
pk
):
order
=
get_object_or_404
(
Order
,
pk
=
pk
)
if
request
.
GET
.
get
(
'message'
)
==
None
:
context
=
{
"order"
:
order
}
else
:
context
=
{
"order"
:
order
,
'message'
:
request
.
GET
.
get
(
'message'
)}
return
render
(
request
,
'Kiosk/view_order_details.html'
,
context
)
def
update_order
(
request
,
pk
):
...
...
@@ -72,7 +75,8 @@ def update_order(request, pk):
qty
=
request
.
POST
.
get
(
'qty'
)
payment_mode
=
request
.
POST
.
get
(
'payment_mode'
)
Order
.
objects
.
filter
(
pk
=
pk
)
.
update
(
qty
=
qty
,
payment_mode
=
payment_mode
)
return
redirect
(
'view_order_details'
,
pk
=
pk
)
message
=
"Order updated successfully"
return
redirect
(
f
'/view_order_details/{pk}?message={message}'
,
pk
=
pk
)
else
:
order
=
get_object_or_404
(
Order
,
pk
=
pk
)
context
=
{
"order"
:
order
}
...
...
@@ -100,7 +104,8 @@ def add_order(request):
payment_mode
=
payment_mode
)
return
redirect
(
'home'
)
message
=
"Order created successfully"
return
redirect
(
f
"/home?message={message}"
)
except
Exception
as
e
:
message
=
e
...
...
@@ -112,7 +117,8 @@ def add_order(request):
def
delete_order
(
request
,
pk
):
Order
.
objects
.
filter
(
pk
=
pk
)
.
delete
()
return
redirect
(
'home'
)
message
=
"Order deleted successfully"
return
redirect
(
f
'/home?message={message}'
)
### Views for Food Model
def
view_foods
(
request
):
...
...
@@ -142,9 +148,17 @@ def update_food(request, pk):
description
=
request
.
POST
.
get
(
'description'
)
price
=
request
.
POST
.
get
(
'price'
)
created_at
=
request
.
POST
.
get
(
'date'
)
try
:
Food
.
objects
.
filter
(
pk
=
pk
)
.
update
(
name
=
name
,
description
=
description
,
price
=
price
,
created_at
=
created_at
)
message
=
"Food updated successfully"
return
redirect
(
f
'/view_food_details/{pk}?message={message}'
,
pk
=
pk
)
except
Exception
as
e
:
message
=
f
"Food name '{name}' already exists"
food
=
get_object_or_404
(
Food
,
pk
=
pk
)
context
=
{
"food"
:
food
,
"message"
:
message
}
return
render
(
request
,
'Kiosk/update_food.html'
,
context
)
else
:
food
=
get_object_or_404
(
Food
,
pk
=
pk
)
context
=
{
"food"
:
food
}
...
...
@@ -165,7 +179,7 @@ def add_food(request):
created_at
=
created_at
,
)
message
=
request
.
POST
.
get
(
'message'
)
message
=
"Food created successfully"
return
redirect
(
f
"/foods?message={message}"
)
except
Exception
as
e
:
...
...
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