mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
add url image product
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -15,4 +15,4 @@ class Product(models.Model):
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
return f"{self.id} - {self.name} - {self.price} - {self.category} - {self.cuisine} - {self.active} "
|
||||
@@ -36,6 +36,8 @@ Produtos
|
||||
<td id="name-{{product.id}}" >{{product.name}}</td>
|
||||
<td id="price-{{product.id}}" >R$ {{product.price}}</td>
|
||||
<td class="hide-on-mobile" id="quantity-{{product.id}}" >{{product.quantity}}</td>
|
||||
<td hidden class="hide-on-mobile" id="image-{{product.id}}" >{{product.image}}</td>
|
||||
|
||||
<td class="hide-on-mobile" id="category-{{product.id}}" >{{product.category.name}}</td>
|
||||
<td >
|
||||
<div class="grid-buttons">
|
||||
@@ -86,15 +88,20 @@ Produtos
|
||||
</body>
|
||||
|
||||
<dialog id='Modal-create-product' >
|
||||
<article >
|
||||
<form action="{% url 'create_product' %}" id="productForm" method="post" >
|
||||
<article id="modal-product" class="modal-product">
|
||||
<form style="z-index: 1000; position: relative;" action="{% url 'create_product' %}" id="productForm" method="post" >
|
||||
|
||||
{% csrf_token %}
|
||||
<h2>Cadastro de Produto</h2>
|
||||
<!-- <div style="height: 200px;border-radius: 15px;">
|
||||
<img id="image-product" src="" alt="">
|
||||
</div> -->
|
||||
<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">
|
||||
<input type="text" id="url-image" name="image" required placeholder="URL da imagem">
|
||||
|
||||
<div>
|
||||
<input type="checkbox" id="cuisine" name="cuisine" placeholder="Cozinha">Cozinha
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,10 @@ from gestaoRaul.decorators import group_required
|
||||
def products(request):
|
||||
protucts = Product.objects.all()
|
||||
categories = Categories.objects.all()
|
||||
# teste = Product.objects.get(id=389)
|
||||
# teste.image = "https://ehgomes.com.br/wp-content/uploads/2023/08/Vectorizer.AI-A-Ferramenta-que-Transforma-Imagens-em-Vetores.webp"
|
||||
# teste.save()
|
||||
# print((teste.image))
|
||||
return render(request, 'products.html', {'products': protucts, 'categories': categories})
|
||||
|
||||
@group_required(groupName='Garçom')
|
||||
@@ -51,6 +55,7 @@ def editProduct(request, productId):
|
||||
product.description = request.POST.get('description')
|
||||
product.price = request.POST.get('price')
|
||||
product.quantity = request.POST.get('qtd')
|
||||
product.image = request.POST.get('image')
|
||||
product.cuisine = True if request.POST.get('cuisine') else False
|
||||
product.category = Categories.objects.get(id = int(request.POST.get('select-categorie')))
|
||||
product.save()
|
||||
|
||||
Reference in New Issue
Block a user