mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
editor product cuisine
This commit is contained in:
Binary file not shown.
@@ -49,8 +49,9 @@ Produtos
|
||||
|
||||
<input type="hidden" id="h-category-{{product.id}}" value="{{ product.category.id }}">
|
||||
<input type="hidden" id="description-{{product.id}}" value="{{ product.description }}">
|
||||
<input type="hidden" id="cuisine-{{product.id}}" value="{{ product.cuisine }}">
|
||||
|
||||
<form action="{% url 'onOffproduct' %}" method="post">
|
||||
<form hx-post="{% url 'onOffproduct' %}" hx-trigger="click" hx-target="#product-list">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="id-product" id="id-{{product.id}}" value="{{ product.id }}">
|
||||
|
||||
@@ -90,10 +91,13 @@ Produtos
|
||||
|
||||
{% csrf_token %}
|
||||
<h2>Cadastro de Produto</h2>
|
||||
<input type="text" id="productId" name="productId" hidden ><br>
|
||||
<input type="text" id="productName" name="name" required placeholder="Nome"><br>
|
||||
<input type="number" step="0.01" id="productPrice" name="price" required placeholder="Preço"><br>
|
||||
<input type="number" step="1" id="productqtd" name="qtd" placeholder="Quantidade"><br>
|
||||
<input type="text" id="productId" name="productId" hidden >
|
||||
<input type="text" id="productName" name="name" required placeholder="Nome">
|
||||
<input type="number" step="0.01" id="productPrice" name="price" required placeholder="Preço">
|
||||
<input type="number" step="1" id="productqtd" name="qtd" placeholder="Quantidade">
|
||||
<div>
|
||||
<input type="checkbox" id="cuisine" name="cuisine" placeholder="Cozinha">Cozinha
|
||||
</div>
|
||||
<select id="select-categorie" name="select-categorie" >
|
||||
|
||||
{% for categorie in categories %}
|
||||
@@ -101,7 +105,7 @@ Produtos
|
||||
{% endfor %}
|
||||
|
||||
</select>
|
||||
<textarea id="productDescription" name="description" rows="4" placeholder="Descrição"></textarea><br>
|
||||
<textarea id="productDescription" name="description" rows="4" placeholder="Descrição"></textarea>
|
||||
<footer class="grid-buttons">
|
||||
<button id="save" type="submit">Salvar</button>
|
||||
<button onclick="closeModal()" type="button" id="edit" hx-post="{% url 'editProduct' 1 %}" hx-trigger="click" hx-target="#product-list" >Alterar</button>
|
||||
|
||||
@@ -23,7 +23,6 @@ def createProduct(request):
|
||||
product = Product(name=name, description=description, price=price, category=category)
|
||||
product.save()
|
||||
return redirect('/products')
|
||||
# return render(request, 'products.html')
|
||||
|
||||
|
||||
def onOffProduct(request):
|
||||
@@ -32,10 +31,11 @@ def onOffProduct(request):
|
||||
product = Product.objects.get(id=product_id)
|
||||
product.active = not product.active
|
||||
product.save()
|
||||
return redirect('products')
|
||||
products = Product.objects.all()
|
||||
return render(request, "htmx_components/products/htmx_search_products.html", {"products": products})
|
||||
|
||||
|
||||
def editProduct(request, productId):
|
||||
print('wwwwwwwwwwwwwwwwwwwwwwww ', request.POST.get('productId'),' ooooooooooo')
|
||||
product_id = int(request.POST.get('productId'))
|
||||
# product_id = productId
|
||||
product = Product.objects.get(id=product_id)
|
||||
@@ -43,13 +43,11 @@ def editProduct(request, productId):
|
||||
product.description = request.POST.get('description')
|
||||
product.price = request.POST.get('price')
|
||||
product.quantity = request.POST.get('qtd')
|
||||
product.cuisine = True if request.POST.get('cuisine') else False
|
||||
product.category = Categories.objects.get(id = int(request.POST.get('select-categorie')))
|
||||
product.save()
|
||||
print(request.GET.get("search-product"))
|
||||
product = request.GET.get("search-product")
|
||||
if product == None:
|
||||
product = ''
|
||||
products = Product.objects.filter(name__icontains=product)
|
||||
return render(request, "htmx_components/products/htmx_search_products.html", {"products": products})
|
||||
# return render(request, 'products.html')
|
||||
# return redirect('/products')
|
||||
Reference in New Issue
Block a user