Commit f4ca1637 authored by Jansen Lao's avatar Jansen Lao

7

parent f74cd87b
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block content %}
<div class="card w-75">
<div class="card-header">
Enter Food Details:
</div>
<form method="POST" action="{% url 'add_food' %}">{% csrf_token %}
<div class="form-group">
<label for="name"> Food Name: </label>
<input type="text" class="form-control" id="food_name" name="food_name" required>
</div>
<div class="form-group">
<label for="name"> Description: </label>
<input type="text" class="form-control" id="description" name="description" required>
</div>
<div class="form-group">
<label for="name"> Price: </label>
<input type="number" class="form-control" id="price" name="price" required>
</div>
<div class="form-group">
<label for="name"> Date Created: </label>
<input type="date" class="form-control" id="date" name="date" required>
</div>
<a href="{% url 'add_food' %}"><button type="submit" class="mt-3 btn btn-primary">Add Food</button></a>
</form>
</div>
{% endblock %}
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
Matthew Dizon | 191735 Matthew Dizon | 191735
</li> </li>
<li class="nav-item mx-2"> <li class="nav-item mx-2">
Jansen Lao | 191735 Jansen Lao | 192729
</li> </li>
</ul> </ul>
</nav> </nav>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<div class="container"> <div class="container">
<h1 class="jumbotron-heading">Food Items</h1> <h1 class="jumbotron-heading">Food Items</h1>
<p>A table of all food items</p> <p>A table of all food items</p>
<a href="{% url 'add_food' %}"><button class="btn btn-dark">Add Food</button></a>
</div> </div>
</section> </section>
......
...@@ -13,6 +13,7 @@ urlpatterns = [ ...@@ -13,6 +13,7 @@ urlpatterns = [
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('add_order', views.add_order, name="add_order"),
# Path for Food Model # Path for Food Model
path('add_food', views.add_food, name="add_food"),
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"),
# Path for Customer Model # Path for Customer Model
......
...@@ -107,6 +107,32 @@ def add_order(request): ...@@ -107,6 +107,32 @@ def add_order(request):
else: else:
return render(request, 'Kiosk/add_order.html', context) 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')
### Views for Food Model ### Views for Food Model
def view_foods(request): def view_foods(request):
foods = Food.objects.all() foods = Food.objects.all()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment