Created new forms and views accordingly for functioning order and inventory views

parent fb8ba6c0
{% extends 'blizzardblast\templates\base.html' %}
{% load static %}
{% block title %}Add Customer{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form action="/addBaseFlavor" method="POST" style="text-align:center">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'blizzardblast\templates\base.html' %}
{% load static %}
{% block title %}Add Customer{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form action="/addcustomer" method="POST" style="text-align:center">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'blizzardblast\templates\base.html' %}
{% load static %}
{% block title %}Add order{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form action="/addingredient" method="POST" style="text-align:center">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'blizzardblast\templates\base.html' %}
{% load static %}
{% block title %}Add Ingredient in Inventory{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form action="/addinventory" method="post" style="text-align:center">
{% csrf_token %}
{{inventory_form.as_p}}
<input type="submit" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'blizzardblast\templates\base.html' %}
{% load static %}
{% block title %}Add item{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form action="/additem" method="POST" style="text-align:center">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'blizzardblast\templates\base.html' %}
{% load static %}
{% block title %}Add order{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form action="/addorder" method="POST" style="text-align:center">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
from django import forms
from django.forms import (ModelForm,
TextInput, Textarea, widgets)
from .models import Customer, Orders, Item
from .models import *
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')
class AddItemForm(forms.ModelForm):
class Meta:
model = Item
fields = '__all__'
class AddCustomerForm(forms.ModelForm):
class Meta:
model = Customer
fields = '__all__'
class AddIngredient(forms.ModelForm):
class Meta:
model = Ingredient
fields = '__all__'
class AddBaseFlavor(forms.ModelForm):
class Meta:
model = BaseFlavor
fields = '__all__'
INGREDIENT_CATEGORIES = (
(1,'nuts'),
......
......@@ -14,6 +14,10 @@ urlpatterns = [
#forms
path('addorder', addorder, name='addorder'),
path('additem', additem, name='additem'),
path('addcustomer', addcustomer, name='addcustomer'),
path('addingredient', addingredient, name='addingredient'),
path('addBaseFlavor', addbaseflavor, name='addBaseFlavor'),
path('addinventory', addinventory, name='addinventory'),
#queries
......
from django.shortcuts import render, redirect
from django.http import HttpResponse
from .forms import AddInventoryForm, AddOrderForm
from .forms import *
from .models import *
# ========================== MAIN VIEWS ==========================
def homepage(request):
return render(request, "blizzardblast/templates/index.html")
def order(request):
orders_context = Orders.objects.all()
return render(request, "blizzardblast/templates/order.html", {'orders': orders_context})
def receipt(request):
return render(request, "blizzardblast/templates/receipt.html")
def inventory(request):
return render(request, "blizzardblast/templates/inventory.html")
ingredients_context = Ingredient.objects.all()
base_flavor_context = BaseFlavor.objects.all()
contexts = {
'baseflavor' : base_flavor_context,
'inventory' : ingredients_context
}
return render(request, "blizzardblast/templates/inventory.html", contexts)
def schedule(request):
all_values = EmployeeRole.objects.all()
# 5: FILTER EMPLOYEES AND ROLES BY DATE IN ORDER - xx
date_order_query = EmployeeRole.objects.all().order_by('role_date')
return render(request, "blizzardblast/templates/schedule.html", {
'all_values': all_values
}
return render(request,
"blizzardblast/templates/schedule.html",
{'all_values': all_values}
)
def report(request):
return render(request, "blizzardblast/templates/report.html")
# ========================== SCHEDULE QUERIES ==========================
# 1: FILTER EMPLOYEES BY MANAGER FOR THE DAY - mate
def manager_query(request):
ismanager_query = EmployeeRole.objects.all().filter(is_manager='Y')
......@@ -74,17 +75,11 @@ def alphabetical_query(request):
})
def report(request):
return render(request, "blizzardblast/templates/report.html")
# FORMS
# ========================== FORMS ==========================
def addorder(request):
form = AddOrderForm()
context = {
'form': form
}
context = {'form': form }
if request.method == 'POST':
#print("Printing post: ", request.POST)
......@@ -93,9 +88,48 @@ def addorder(request):
form.save()
return redirect('/order')
return render(request, "blizzardblast/templates/addorder.html", context)
return render(request, "blizzardblast/templates/forms/addorder.html", context)
def additem(request):
form = AddItemForm()
context = {'form':form}
if request.method == 'POST':
form = AddItemForm(request.POST)
if form.is_valid():
form.save()
return redirect('/order')
return render(request, "blizzardblast/templates/forms/additem.html", context)
def addcustomer(request):
form = AddCustomerForm()
context = {'form':form}
if request.method == 'POST':
form = AddCustomerForm(request.POST)
if form.is_valid():
form.save()
return redirect('/order')
return render(request, "blizzardblast/templates/forms/addcustomer.html", context)
def addingredient(request):
form = AddIngredient()
context = {'form':form}
if request.method == 'POST':
form = AddIngredient(request.POST)
if form.is_valid():
form.save()
return redirect('/inventory')
return render(request, "blizzardblast/templates/forms/addingredient.html", context)
def addbaseflavor(request):
form = AddBaseFlavor()
context = {'form':form}
if request.method == 'POST':
form = AddBaseFlavor(request.POST)
if form.is_valid():
form.save()
return redirect('/inventory')
return render(request, "blizzardblast/templates/forms/addBaseFlavor.html", context)
def addinventory(request):
form = AddInventoryForm()
return render(request, "blizzardblast/templates/addinventory.html", {'form':form})
return render(request, "blizzardblast/templates/forms/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