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

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