Commit f4c47c40 authored by Matthew Dizon's avatar Matthew Dizon

formatted views.py

parent e346d596
Pipeline #1920 canceled with stages
...@@ -3,30 +3,6 @@ from .models import * ...@@ -3,30 +3,6 @@ from .models import *
# Create your views here. # Create your views here.
def home(request):
orders = Order.objects.all()
context = {"orders": orders}
return render(request, 'Kiosk/home.html', context)
def view_order_details(request, pk):
order = get_object_or_404(Order, pk=pk)
context = {"order": order}
# url = request.META.get('HTTP_REFERER')
# request.session['url'] = url
# print(url)
return render(request, 'Kiosk/view_order_details.html', context)
def update_order(request, pk):
if(request.method=="POST"):
qty = request.POST.get('qty')
payment_mode = request.POST.get('payment_mode')
Order.objects.filter(pk=pk).update(qty=qty, payment_mode=payment_mode)
return redirect('view_order_details', pk=pk)
else:
order = get_object_or_404(Order, pk=pk)
context = {"order": order}
return render(request, 'Kiosk/update_order.html', context)
### Views for Account Model ### Views for Account Model
def login_view(request): def login_view(request):
if request.method == "POST": if request.method == "POST":
...@@ -77,8 +53,28 @@ def signup_view(request): ...@@ -77,8 +53,28 @@ def signup_view(request):
def logout_view(request): def logout_view(request):
return redirect('/') return redirect('/')
### Views for Food Model ### Views for Order Model
def home(request):
orders = Order.objects.all()
context = {"orders": orders}
return render(request, 'Kiosk/home.html', context)
### Views for Customer Model def view_order_details(request, pk):
order = get_object_or_404(Order, pk=pk)
context = {"order": order}
return render(request, 'Kiosk/view_order_details.html', context)
def update_order(request, pk):
if(request.method=="POST"):
qty = request.POST.get('qty')
payment_mode = request.POST.get('payment_mode')
Order.objects.filter(pk=pk).update(qty=qty, payment_mode=payment_mode)
return redirect('view_order_details', pk=pk)
else:
order = get_object_or_404(Order, pk=pk)
context = {"order": order}
return render(request, 'Kiosk/update_order.html', context)
### Views for Food Model
### Views for Order Model ### Views for Customer Model
\ No newline at end of file \ 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