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
077699b1
Commit
077699b1
authored
May 27, 2021
by
Jansen Lao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
7agen
parent
459822c4
Pipeline
#1929
canceled with stages
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
7 deletions
+57
-7
update_food.html
GrabGrub/Kiosk/templates/Kiosk/update_food.html
+32
-0
view_food_details.html
GrabGrub/Kiosk/templates/Kiosk/view_food_details.html
+4
-7
urls.py
GrabGrub/Kiosk/urls.py
+2
-0
views.py
GrabGrub/Kiosk/views.py
+19
-0
No files found.
GrabGrub/Kiosk/templates/Kiosk/update_food.html
0 → 100644
View file @
077699b1
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block content %}
<div
class=
"card w-75"
>
<div
class=
"card-header"
>
Food Details:
</div>
<form
method=
"POST"
action=
"{% url 'update_food' pk=food.pk %}"
>
{% csrf_token %}
<div
class=
"form-group"
>
<label
for=
"name"
>
Food Name:
</label>
<input
type=
"text"
class=
"form-control"
id=
"food_name"
name=
"food_name"
value=
"{{food.name}}"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"name"
>
Description:
</label>
<input
type=
"text"
class=
"form-control"
id=
"description"
name=
"description"
value=
"{{food.description}}"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"name"
>
Price:
</label>
<input
type=
"number"
class=
"form-control"
id=
"price"
name=
"price"
value=
"{{food.price}}"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"name"
>
Date Created:
</label>
<input
type=
"date"
class=
"form-control"
id=
"date"
name=
"date"
value=
"{{food.created_at}}"
required
>
</div>
<a
href=
"{% url 'update_food' food.pk %}"
><button
type=
"submit"
class=
"mt-3 btn btn-primary"
>
Update Food
</button></a>
</form>
</div>
<a
href=
"{% url 'view_food_details' food.pk %}"
><button
class=
"btn btn-secondary"
>
Back
</button></a>
{% endblock %}
GrabGrub/Kiosk/templates/Kiosk/view_food_details.html
View file @
077699b1
...
...
@@ -13,11 +13,8 @@
<li
class=
"list-group-item"
><span
style=
"color: #8AB4F8; font-weight:bold"
>
Customer:
</span>
{{food.created_at}}
</li>
</ul>
</div>
<form
action=
"#"
method=
"post"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"message"
value=
"Bottle deleted successfully"
>
<a
href=
"#"
><button
class=
"btn btn-secondary my-4"
>
Delete Food
</button></a>
</form>
<a
href=
"#"
><button
type=
"submit"
class=
"mt-3 btn btn-primary"
>
Update Food
</button></a>
<a
onclick=
"window.history.go(-1); return false;"
><button
class=
"btn btn-secondary"
>
Back
</button></a>
<a
href=
"{% url 'delete_food' food.pk %}"
><button
class=
"btn btn-danger my-4"
>
Delete Food
</button></a>
<a
href=
"{% url 'update_food' food.pk %}"
><button
type=
"submit"
class=
"btn btn-primary"
>
Update Food
</button></a>
<a
href=
"{% url 'view_foods' %}"
><button
class=
"btn btn-secondary"
>
Back
</button></a>
{% endblock %}
\ No newline at end of file
GrabGrub/Kiosk/urls.py
View file @
077699b1
...
...
@@ -15,8 +15,10 @@ urlpatterns = [
path
(
'delete_order/<int:pk>'
,
views
.
delete_order
,
name
=
"delete_order"
),
# Path for Food Model
path
(
'add_food'
,
views
.
add_food
,
name
=
"add_food"
),
path
(
'update_food/<int:pk>'
,
views
.
update_food
,
name
=
"update_food"
),
path
(
'foods'
,
views
.
view_foods
,
name
=
"view_foods"
),
path
(
'view_food_details/<int:pk>'
,
views
.
view_food_details
,
name
=
"view_food_details"
),
path
(
'delete_food/<int:pk>'
,
views
.
delete_food
,
name
=
"delete_food"
),
# Path for Customer Model
path
(
'customers'
,
views
.
view_customers
,
name
=
"view_customers"
),
path
(
'view_customer_details/<int:pk>'
,
views
.
view_customer_details
,
name
=
"view_customer_details"
),
...
...
GrabGrub/Kiosk/views.py
View file @
077699b1
...
...
@@ -136,6 +136,8 @@ def delete_order(request, pk):
Order
.
objects
.
filter
(
pk
=
pk
)
.
delete
()
return
redirect
(
'home'
)
### Views for Food Model
def
view_foods
(
request
):
foods
=
Food
.
objects
.
all
()
...
...
@@ -147,6 +149,23 @@ def view_food_details(request, pk):
context
=
{
"food"
:
food
}
return
render
(
request
,
'Kiosk/view_food_details.html'
,
context
)
def
delete_food
(
request
,
pk
):
Food
.
objects
.
filter
(
pk
=
pk
)
.
delete
()
return
redirect
(
'view_foods'
)
def
update_food
(
request
,
pk
):
if
(
request
.
method
==
"POST"
):
name
=
request
.
POST
.
get
(
'food_name'
)
description
=
request
.
POST
.
get
(
'description'
)
price
=
request
.
POST
.
get
(
'price'
)
created_at
=
request
.
POST
.
get
(
'date'
)
Food
.
objects
.
filter
(
pk
=
pk
)
.
update
(
name
=
name
,
description
=
description
,
price
=
price
,
created_at
=
created_at
)
return
redirect
(
'view_food_details'
,
pk
=
pk
)
else
:
food
=
get_object_or_404
(
Food
,
pk
=
pk
)
context
=
{
"food"
:
food
}
return
render
(
request
,
'Kiosk/update_food.html'
,
context
)
### Views for Customer Model
def
view_customers
(
request
):
customers
=
Customer
.
objects
.
all
()
...
...
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