Fixed the order.html according to the models.py file.

Adjusted views, forms and cleaned urls.py
parent 9561791c
{% extends 'blizzardblast\templates\base.html' %} {% extends 'blizzardblast\templates\base.html' %}
{% load static %} {% load static %}
{% block title %}Create Order{% endblock %} {% block title %}Order{% endblock %}
{% block styles %} {% block styles %}
{% endblock %} {% endblock %}
...@@ -31,39 +31,21 @@ ...@@ -31,39 +31,21 @@
<table> <table>
<!-- TABLE HEADER --> <!-- TABLE HEADER -->
<tr> <tr>
<th>customer_no</th>
<th>customer_name</th> <th>customer_name</th>
<th>date</th> <th>date</th>
<th>size</th> <th>item</th>
<th>base_recipe</th> <th>Employee in charge</th>
<th>add_on_qty</th>
<th>add_on_name</th>
</tr> </tr>
<!-- TABLE ROW WITH INFO --> <!-- TABLE ROW WITH INFO -->
{% for order in orders%}
<tr> <tr>
<td>2039</td> <td>{{order.customer}}</td>
<td>Anna Doe</td> <td>{{order.order_date}}</td>
<td>11/13/15</td> <td>{{order.item}}</td>
<td>12 oz</td> <td>{{order.employee}}</td>
<td>base_receipe</td>
<td>1</td>
<td>
mini marshmallows,<br>
strawberry
</td>
</tr>
<!-- TABLE ROW WITHOUT INFO -->
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr> </tr>
{%endfor%}
</table> </table>
</div> </div>
......
from django import forms from django import forms
from django.forms import (ModelForm,
TextInput, Textarea, widgets)
from .models import Customer, Orders, Item
class AddOrderForm(forms.ModelForm):
class AddOrderForm(forms.Form): class Meta:
customer_no = forms.IntegerField(label='Customer no') model = Orders
customer_name = forms.CharField(label='Customer Name', max_length=50) fields = '__all__'
date = forms.DateField(label='Date') # customer_no = forms.IntegerField(label='Customer no')
base_recipe = forms.CharField(label='Base Recipe') # customer_name = forms.CharField(label='Customer Name', max_length=50)
add_on_qty = forms.IntegerField(label='Add-on Qty') # date = forms.DateField(label='Date')
add_on_name = forms.CharField(label='Add-on') # base_recipe = forms.CharField(label='Base Recipe')
# add_on_qty = forms.IntegerField(label='Add-on Qty')
# add_on_name = forms.CharField(label='Add-on')
INGREDIENT_CATEGORIES = ( INGREDIENT_CATEGORIES = (
(1,'nuts'), (1,'nuts'),
......
...@@ -2,14 +2,21 @@ from django.urls import path, include ...@@ -2,14 +2,21 @@ from django.urls import path, include
from .views import * from .views import *
urlpatterns = [ urlpatterns = [
# main views
path('', homepage, name='homepage'), path('', homepage, name='homepage'),
# order view
path('order', order, name='order'), path('order', order, name='order'),
path('receipt', receipt, name='receipt'),
path('inventory', inventory, name='inventory'), path('inventory', inventory, name='inventory'),
path('schedule', schedule, name='schedule'), path('schedule', schedule, name='schedule'),
path('report', report, name='report'), path('report', report, name='report'),
path('receipt', receipt, name='receipt'),
#forms
path('addorder', addorder, name='addorder'), path('addorder', addorder, name='addorder'),
path('addinventory', addinventory, name='addinventory'), path('addinventory', addinventory, name='addinventory'),
#queries
path('manager_query', manager_query, name='manager_query'), path('manager_query', manager_query, name='manager_query'),
path('week_query', week_query, name='week_query'), path('week_query', week_query, name='week_query'),
path('role_query', role_query, name='role_query'), path('role_query', role_query, name='role_query'),
......
from django.shortcuts import render from django.shortcuts import render, redirect
from django.http import HttpResponse from django.http import HttpResponse
from .forms import AddInventoryForm, AddOrderForm from .forms import AddInventoryForm, AddOrderForm
from .models import * from .models import *
def homepage(request): def homepage(request):
return render(request, "blizzardblast/templates/index.html") return render(request, "blizzardblast/templates/index.html")
def order(request): def order(request):
return render(request, "blizzardblast/templates/order.html")
orders_context = Orders.objects.all()
return render(request, "blizzardblast/templates/order.html", {'orders': orders_context})
def receipt(request): def receipt(request):
...@@ -74,11 +78,24 @@ def report(request): ...@@ -74,11 +78,24 @@ def report(request):
return render(request, "blizzardblast/templates/report.html") return render(request, "blizzardblast/templates/report.html")
# FORMS
def addorder(request): def addorder(request):
form = AddOrderForm() form = AddOrderForm()
return render(request, "blizzardblast/templates/addorder.html", {'form': form})
context = {
'form': form
}
if request.method == 'POST':
#print("Printing post: ", request.POST)
form = AddOrderForm(request.POST)
if form.is_valid():
form.save()
return redirect('/order')
return render(request, "blizzardblast/templates/addorder.html", context)
def addinventory(request): def addinventory(request):
form = AddInventoryForm() form = AddInventoryForm()
return render(request, "blizzardblast/templates/addinventory.html", {'inventory_form': form}) return render(request, "blizzardblast/templates/addinventory.html", {'form':form})
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