Skip to content
Snippets Groups Projects
Commit 52bf8ec5 authored by Christian Dresen's avatar Christian Dresen
Browse files

[WarpFood] Add orders to database

parent 79c1c90d
No related branches found
No related tags found
No related merge requests found
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
<div class="tab-content"> <div class="tab-content">
{% for category,products in food_products.items %} {% for category,products in food_products.items %}
<div role="tabpanel" class="tab-pane fade in{% if category == "Pizza" %} active {% endif %}" id="{{ category }}"> <div role="tabpanel" class="tab-pane fade in{% if category == "all" %} active {% endif %}" id="{{ category }}">
<table class="table table-striped table-hover"> <table class="table table-striped table-hover">
{% for product in products %} {% for product in products %}
<tr data-link="javascript:choose_food_product('{{ product.name }}','{{ product.size }}','{{ product.price }}', '{{ product.id }}');"> <tr data-link="javascript:choose_food_product('{{ product.name }}','{{ product.size }}','{{ product.price }}', '{{ product.id }}');">
......
...@@ -51,7 +51,6 @@ def edit_sheet(request, sheet_id=0): ...@@ -51,7 +51,6 @@ def edit_sheet(request, sheet_id=0):
return redirect("/") return redirect("/")
def view(request, sheet_id=0): def view(request, sheet_id=0):
form = None form = None
page_context['error'] = "" page_context['error'] = ""
...@@ -61,7 +60,15 @@ def view(request, sheet_id=0): ...@@ -61,7 +60,15 @@ def view(request, sheet_id=0):
else: else:
form = FoodOrderFormExt(request.POST) form = FoodOrderFormExt(request.POST)
if form.is_valid(): if form.is_valid():
form.save() order = form.save()
if not order.product_id:
p = FoodProduct()
p.name = order.article
p.food_service = order.sheet.food_service
p.food_category = FoodCategory.objects.get(name="not_assigned")
p.size = order.size
p.price = order.price
p.save()
form = None form = None
if sheet_id != 0: if sheet_id != 0:
...@@ -83,11 +90,14 @@ def view(request, sheet_id=0): ...@@ -83,11 +90,14 @@ def view(request, sheet_id=0):
products = FoodProduct.objects.filter(food_service=sheet.food_service) products = FoodProduct.objects.filter(food_service=sheet.food_service)
page_context['food_products'] = {} page_context['food_products'] = {}
page_context['food_products']['all']=[]
for product in products: for product in products:
if product.food_category.name not in page_context['food_products']: if product.food_category.name not in page_context['food_products']:
page_context['food_products'][product.food_category.name] = [] page_context['food_products'][product.food_category.name] = []
page_context['food_products']['all'].append(product)
page_context['food_products'][product.food_category.name].append(product) page_context['food_products'][product.food_category.name].append(product)
return HttpResponse(render(request, 'warpfood/view.html', page_context)) return HttpResponse(render(request, 'warpfood/view.html', page_context))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment