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
e0299609
Commit
e0299609
authored
May 29, 2021
by
Matthew Dizon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.discs.ateneo.edu/nozid_matthew/grabgrub
parents
f8f46fa6
04ee3338
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
5 deletions
+36
-5
update_customer.html
GrabGrub/Kiosk/templates/Kiosk/update_customer.html
+3
-0
update_food.html
GrabGrub/Kiosk/templates/Kiosk/update_food.html
+3
-0
view_customer_details.html
GrabGrub/Kiosk/templates/Kiosk/view_customer_details.html
+3
-0
view_customers.html
GrabGrub/Kiosk/templates/Kiosk/view_customers.html
+4
-0
views.py
GrabGrub/Kiosk/views.py
+23
-5
No files found.
GrabGrub/Kiosk/templates/Kiosk/update_customer.html
View file @
e0299609
...
...
@@ -24,4 +24,7 @@
</div>
<br>
<a
href=
"{% url 'view_customer_details' customer.pk %}"
><button
class=
"btn btn-secondary"
>
Back
</button></a>
{% if message %}
<p
class=
"mt-3 alert alert-danger"
style=
"width: 75%"
>
{{message}}
</p>
{% endif %}
{% endblock %}
GrabGrub/Kiosk/templates/Kiosk/update_food.html
View file @
e0299609
...
...
@@ -30,4 +30,7 @@
</div>
<br>
<a
href=
"{% url 'view_food_details' food.pk %}"
><button
class=
"btn btn-secondary"
>
Back
</button></a>
{% if message %}
<p
class=
"mt-3 alert alert-danger"
style=
"width: 75%"
>
{{message}}
</p>
{% endif %}
{% endblock %}
GrabGrub/Kiosk/templates/Kiosk/view_customer_details.html
View file @
e0299609
...
...
@@ -16,4 +16,7 @@
<a
href=
"{% url 'update_customer' customer.pk %}"
><button
type=
"submit"
class=
"btn btn-primary"
>
Update Customer
</button></a>
<a
href=
"{% url 'delete_customer' customer.pk %}"
><button
class=
"btn btn-danger my-4"
>
Delete Customer
</button></a>
<a
href=
"{% url 'view_customers' %}"
><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_customers.html
View file @
e0299609
...
...
@@ -9,6 +9,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 @
e0299609
...
...
@@ -151,6 +151,7 @@ def update_food(request, pk):
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
:
...
...
@@ -195,25 +196,42 @@ def add_food(request):
### Views for Customer Model
def
view_customers
(
request
):
customers
=
Customer
.
objects
.
all
()
if
request
.
GET
.
get
(
'message'
)
==
None
:
context
=
{
"customers"
:
customers
}
else
:
context
=
{
"customers"
:
customers
,
'message'
:
request
.
GET
.
get
(
'message'
)}
return
render
(
request
,
'Kiosk/view_customers.html'
,
context
)
def
view_customer_details
(
request
,
pk
):
customer
=
get_object_or_404
(
Customer
,
pk
=
pk
)
if
request
.
GET
.
get
(
'message'
)
==
None
:
context
=
{
"customer"
:
customer
}
else
:
context
=
{
"customer"
:
customer
,
'message'
:
request
.
GET
.
get
(
'message'
)}
return
render
(
request
,
'Kiosk/view_customer_details.html'
,
context
)
def
delete_customer
(
request
,
pk
):
Customer
.
objects
.
filter
(
pk
=
pk
)
.
delete
()
return
redirect
(
'view_customers'
)
message
=
"Customer deleted successfully"
return
redirect
(
f
'/customers?message={message}'
)
def
update_customer
(
request
,
pk
):
if
(
request
.
method
==
"POST"
):
customer_name
=
request
.
POST
.
get
(
'customer_name'
)
address
=
request
.
POST
.
get
(
'address'
)
city
=
request
.
POST
.
get
(
'city'
)
try
:
Customer
.
objects
.
filter
(
pk
=
pk
)
.
update
(
name
=
customer_name
,
address
=
address
,
city
=
city
)
return
redirect
(
'view_customer_details'
,
pk
=
pk
)
message
=
"Customer updated successfully"
return
redirect
(
f
'/view_customer_details/{pk}?message={message}'
,
pk
=
pk
)
except
Exception
as
e
:
message
=
f
"Customer with name '{customer_name}' already exists"
customer
=
get_object_or_404
(
Customer
,
pk
=
pk
)
context
=
{
"customer"
:
customer
,
"message"
:
message
}
return
render
(
request
,
'Kiosk/update_customer.html'
,
context
)
else
:
customer
=
get_object_or_404
(
Customer
,
pk
=
pk
)
context
=
{
"customer"
:
customer
}
...
...
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