Commit 077699b1 authored by Jansen Lao's avatar Jansen Lao

7agen

parent 459822c4
Pipeline #1929 canceled with stages
{% 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 %}
...@@ -13,11 +13,8 @@ ...@@ -13,11 +13,8 @@
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Customer: </span> {{food.created_at}}</li> <li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Customer: </span> {{food.created_at}}</li>
</ul> </ul>
</div> </div>
<form action="#" method="post">
{% csrf_token %} <a href="{% url 'delete_food' food.pk %}"><button class="btn btn-danger my-4">Delete Food</button></a>
<input type="hidden" name="message" value="Bottle deleted successfully"> <a href="{% url 'update_food' food.pk %}"><button type="submit" class="btn btn-primary">Update Food</button></a>
<a href="#"><button class="btn btn-secondary my-4">Delete Food</button></a> <a href="{% url 'view_foods' %}"><button class="btn btn-secondary">Back</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>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -15,8 +15,10 @@ urlpatterns = [ ...@@ -15,8 +15,10 @@ urlpatterns = [
path('delete_order/<int:pk>', views.delete_order, name="delete_order"), path('delete_order/<int:pk>', views.delete_order, name="delete_order"),
# Path for Food Model # Path for Food Model
path('add_food', views.add_food, name="add_food"), 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('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('delete_food/<int:pk>', views.delete_food, name="delete_food"),
# Path for Customer Model # Path for Customer Model
path('customers', views.view_customers, name="view_customers"), path('customers', views.view_customers, name="view_customers"),
path('view_customer_details/<int:pk>', views.view_customer_details, name="view_customer_details"), path('view_customer_details/<int:pk>', views.view_customer_details, name="view_customer_details"),
......
...@@ -136,6 +136,8 @@ def delete_order(request, pk): ...@@ -136,6 +136,8 @@ def delete_order(request, pk):
Order.objects.filter(pk=pk).delete() Order.objects.filter(pk=pk).delete()
return redirect('home') return redirect('home')
### Views for Food Model ### Views for Food Model
def view_foods(request): def view_foods(request):
foods = Food.objects.all() foods = Food.objects.all()
...@@ -147,6 +149,23 @@ def view_food_details(request, pk): ...@@ -147,6 +149,23 @@ def view_food_details(request, pk):
context = {"food": food} context = {"food": food}
return render(request, 'Kiosk/view_food_details.html', context) 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 ### Views for Customer Model
def view_customers(request): def view_customers(request):
customers = Customer.objects.all() customers = Customer.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