Commit 09ac6580 authored by Miguel Bandelaria's avatar Miguel Bandelaria

customer functionality

parent 077699b1
Pipeline #1930 canceled with stages
......@@ -17,7 +17,7 @@
<a class="navbar-brand mb-0" href="/">GrabGrub</a>
<ul class="navbar-nav">
<li class="nav-item mx-2">
Miguel Bandelaria | 191735
Miguel Bandelaria | 190518
</li>
<li class="nav-item mx-2">
Matthew Dizon | 191735
......
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block content %}
<div class="card w-75">
<div class="card-header">
Customer Details:
</div>
<form method="POST" action="{% url 'update_customer' pk=customer.pk %}">{% csrf_token %}
<div class="form-group">
<label for="name"> Customer Name: </label>
<input type="text" class="form-control" id="customer_name" name="customer_name" value="{{customer.name}}" required>
</div>
<div class="form-group">
<label for="name"> Address: </label>
<input type="text" class="form-control" id="address" name="address" value="{{customer.address}}" required>
</div>
<div class="form-group">
<label for="name"> City: </label>
<input type="text" class="form-control" id="city" name="city" value="{{customer.city}}" required>
</div>
<a href="{% url 'update_customer' customer.pk %}"><button type="submit" class="mt-3 btn btn-primary">Update Customer</button></a>
</form>
</div>
<a href="{% url 'view_customer_details' customer.pk %}"><button class="btn btn-secondary">Back</button></a>
{% endblock %}
......@@ -7,16 +7,13 @@
Customer Details:
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Food: </span> {{customer.name}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Quantity: </span> {{customer.address}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Date of Order: </span> {{customer.city}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Customer Name: </span> {{customer.name}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Address: </span> {{customer.address}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">City: </span> {{customer.city}}</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 Customer</button></a>
</form>
<a href="#"><button type="submit" class="mt-3 btn btn-primary">Update Customer</button></a>
<a onclick="window.history.go(-1); return false;"><button class="btn btn-secondary">Back</button></a>
<a href="{% url 'delete_customer' customer.pk %}"><button class="btn btn-danger my-4">Delete Customer</button></a>
<a href="{% url 'update_customer' customer.pk %}"><button type="submit" class="btn btn-primary">Update Customer</button></a>
<a href="{% url 'view_customers' %}"><button class="btn btn-secondary">Back</button></a>
{% endblock %}
\ No newline at end of file
......@@ -22,4 +22,6 @@ urlpatterns = [
# 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"),
path('update_customer/<int:pk>', views.update_customer, name="update_customer"),
path('delete_customer/<int:pk>', views.delete_customer, name="delete_customer"),
]
\ No newline at end of file
......@@ -175,4 +175,20 @@ def view_customers(request):
def view_customer_details(request, pk):
customer = get_object_or_404(Customer, pk=pk)
context = {"customer":customer}
return render(request, 'Kiosk/view_customer_details.html', context)
\ No newline at end of file
return render(request, 'Kiosk/view_customer_details.html', context)
def delete_customer(request, pk):
Customer.objects.filter(pk=pk).delete()
return redirect('view_customers')
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')
Customer.objects.filter(pk=pk).update(name=customer_name, address=address, city=city)
return redirect('view_customer_details', pk=pk)
else:
customer = get_object_or_404(Customer, pk=pk)
context = {"customer": customer}
return render(request, 'Kiosk/update_customer.html', context)
\ No newline at end of file
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