diff --git a/www/web/warpfood/templates/warpfood/view.html b/www/web/warpfood/templates/warpfood/view.html index dea9cc2d05e1a6a51a32b9b3dc2ec3f7845621a0..9a6b6a46753c641b8023a63e7e57bc86471bf231 100644 --- a/www/web/warpfood/templates/warpfood/view.html +++ b/www/web/warpfood/templates/warpfood/view.html @@ -137,7 +137,7 @@ <div class="tab-content"> {% 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"> {% for product in products %} <tr data-link="javascript:choose_food_product('{{ product.name }}','{{ product.size }}','{{ product.price }}', '{{ product.id }}');"> diff --git a/www/web/warpfood/views.py b/www/web/warpfood/views.py index 588ba2bc4f7973c74db5b7e5bf8a7be286cfd307..b070b190a0993fd2acec1538e1d10b2a4112bb50 100644 --- a/www/web/warpfood/views.py +++ b/www/web/warpfood/views.py @@ -51,7 +51,6 @@ def edit_sheet(request, sheet_id=0): return redirect("/") - def view(request, sheet_id=0): form = None page_context['error'] = "" @@ -61,7 +60,15 @@ def view(request, sheet_id=0): else: form = FoodOrderFormExt(request.POST) 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 if sheet_id != 0: @@ -83,11 +90,14 @@ def view(request, sheet_id=0): products = FoodProduct.objects.filter(food_service=sheet.food_service) page_context['food_products'] = {} + page_context['food_products']['all']=[] for product in products: if product.food_category.name not in page_context['food_products']: 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) + return HttpResponse(render(request, 'warpfood/view.html', page_context))