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
c0158a29
Commit
c0158a29
authored
May 27, 2021
by
Matthew Dizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
messages with CRUD functionality for food
parent
8ca31adb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
35 deletions
+58
-35
add_food.html
GrabGrub/Kiosk/templates/Kiosk/add_food.html
+6
-2
view_food_details.html
GrabGrub/Kiosk/templates/Kiosk/view_food_details.html
+4
-1
view_foods.html
GrabGrub/Kiosk/templates/Kiosk/view_foods.html
+4
-0
views.py
GrabGrub/Kiosk/views.py
+44
-32
No files found.
GrabGrub/Kiosk/templates/Kiosk/add_food.html
View file @
c0158a29
...
...
@@ -25,13 +25,17 @@
<div
class=
"form-group"
>
<label
for=
"name"
>
Date Created:
</label>
<input
type=
"date"
class=
"form-control"
id=
"date"
name=
"date"
required
>
<label
for=
"name"
>
Date Created:
</label>
<input
type=
"datetime-local"
class=
"form-control"
id=
"date"
name=
"date"
required
>
</div>
<input
type=
"hidden"
name=
"message"
value=
"Food created successfully"
>
<a
href=
"{% url 'add_food' %}"
><button
type=
"submit"
class=
"mt-3 btn btn-primary"
>
Add Food
</button></a>
</form>
</div>
<a
href=
"{% url 'view_foods' %}"
><button
class=
"btn btn-secondary mt-3"
>
Back
</button></a>
{% if message %}
<p
class=
"mt-3 alert alert-danger"
style=
"width: 75%"
>
{{message}}
</p>
{% endif %}
{% endblock %}
GrabGrub/Kiosk/templates/Kiosk/view_food_details.html
View file @
c0158a29
...
...
@@ -14,7 +14,10 @@
</ul>
</div>
<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 'delete_food' food.pk %}"
><button
class=
"btn btn-danger my-4"
>
Delete Food
</button></a>
<a
href=
"{% url 'view_foods' %}"
><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/templates/Kiosk/view_foods.html
View file @
c0158a29
...
...
@@ -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/views.py
View file @
c0158a29
...
...
@@ -56,7 +56,10 @@ def logout_view(request):
### Views for Order Model
def
home
(
request
):
orders
=
Order
.
objects
.
all
()
context
=
{
"orders"
:
orders
}
if
request
.
GET
.
get
(
'message'
)
==
None
:
context
=
{
"orders"
:
orders
}
else
:
context
=
{
"orders"
:
orders
,
'message'
:
request
.
GET
.
get
(
'message'
)}
return
render
(
request
,
'Kiosk/home.html'
,
context
)
def
view_order_details
(
request
,
pk
):
...
...
@@ -107,51 +110,31 @@ def add_order(request):
else
:
return
render
(
request
,
'Kiosk/add_order.html'
,
context
)
### Views for Add Food
def
add_food
(
request
):
if
(
request
.
method
==
"POST"
):
food_name
=
request
.
POST
.
get
(
'food_name'
)
description
=
request
.
POST
.
get
(
'description'
)
price
=
request
.
POST
.
get
(
'price'
)
created_at
=
request
.
POST
.
get
(
'date'
)
try
:
Food
.
objects
.
create
(
name
=
food_name
,
description
=
description
,
price
=
price
,
created_at
=
created_at
,
)
return
redirect
(
'view_foods'
)
except
Exception
as
e
:
message
=
e
print
(
message
)
return
render
(
request
,
'Kiosk/add_food.html'
)
else
:
return
render
(
request
,
'Kiosk/add_food.html'
)
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
()
context
=
{
"foods"
:
foods
}
if
request
.
GET
.
get
(
'message'
)
==
None
:
context
=
{
"foods"
:
foods
}
else
:
context
=
{
"foods"
:
foods
,
'message'
:
request
.
GET
.
get
(
'message'
)}
return
render
(
request
,
'Kiosk/view_foods.html'
,
context
)
def
view_food_details
(
request
,
pk
):
food
=
get_object_or_404
(
Food
,
pk
=
pk
)
context
=
{
"food"
:
food
}
if
request
.
GET
.
get
(
'message'
)
==
None
:
context
=
{
"food"
:
food
}
else
:
context
=
{
"food"
:
food
,
'message'
:
request
.
GET
.
get
(
'message'
)}
return
render
(
request
,
'Kiosk/view_food_details.html'
,
context
)
def
delete_food
(
request
,
pk
):
Food
.
objects
.
filter
(
pk
=
pk
)
.
delete
()
return
redirect
(
'view_foods'
)
message
=
"Food deleted successfully"
return
redirect
(
f
'/foods?message={message}'
)
def
update_food
(
request
,
pk
):
if
(
request
.
method
==
"POST"
):
...
...
@@ -160,12 +143,41 @@ def update_food(request, pk):
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
)
message
=
"Food updated successfully"
return
redirect
(
f
'/view_food_details/{pk}?message={message}'
,
pk
=
pk
)
else
:
food
=
get_object_or_404
(
Food
,
pk
=
pk
)
context
=
{
"food"
:
food
}
return
render
(
request
,
'Kiosk/update_food.html'
,
context
)
def
add_food
(
request
):
if
(
request
.
method
==
"POST"
):
food_name
=
request
.
POST
.
get
(
'food_name'
)
description
=
request
.
POST
.
get
(
'description'
)
price
=
request
.
POST
.
get
(
'price'
)
created_at
=
request
.
POST
.
get
(
'date'
)
try
:
Food
.
objects
.
create
(
name
=
food_name
,
description
=
description
,
price
=
price
,
created_at
=
created_at
,
)
message
=
request
.
POST
.
get
(
'message'
)
return
redirect
(
f
"/foods?message={message}"
)
except
Exception
as
e
:
message
=
e
context
=
{
'message'
:
message
}
return
render
(
request
,
'Kiosk/add_food.html'
,
context
)
else
:
return
render
(
request
,
'Kiosk/add_food.html'
)
### 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