mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 21:45:41 +00:00
estilizando modal produtos
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -4,8 +4,7 @@
|
||||
|
||||
{% block 'head' %}
|
||||
<link rel="stylesheet" href="{% static 'products/css/products.css' %}">
|
||||
<script src="{% static 'products/js/products.js' %}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -21,9 +20,8 @@ Produtos
|
||||
|
||||
<body>
|
||||
<div class="grid-container">
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
|
||||
Abrir Modal
|
||||
</button>
|
||||
<div><input type="text"></div>
|
||||
<button class="button" id="openModal">Adicionar Novo Produto</button>
|
||||
|
||||
{% for product in products %}
|
||||
|
||||
@@ -37,31 +35,23 @@ Produtos
|
||||
</div>
|
||||
</body>
|
||||
|
||||
{% comment %} <dialog open>
|
||||
<h2>Titulo modal</h2>
|
||||
<p>texto qualquer</p>
|
||||
</dialog> {% endcomment %}
|
||||
|
||||
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Título do Modal</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Conteúdo do seu modal.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fechar</button>
|
||||
<button type="button" class="btn btn-primary">Salvar mudanças</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal" id="myModal">
|
||||
<div class="modal-content">
|
||||
<form id="productForm" method="post" action="{% url 'create_product' %}">
|
||||
<h2>Cadastro de Produto</h2>
|
||||
<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" required placeholder="Quantidade"><br>
|
||||
<textarea id="productDescription" name="description" rows="4" required placeholder="Descrição"></textarea><br>
|
||||
<button type="submit">Salvar</button>
|
||||
<button type="button" onclick="closeModal()" style="background-color:red;">Fechar</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="{% static 'products/js/products.js' %}"></script>
|
||||
|
||||
{% endblock %}
|
||||
@@ -4,6 +4,7 @@ from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.products, name='products'),
|
||||
path('create_product', views.createProduct, name='create_product'),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
|
||||
from categories.models import Categories
|
||||
from products.models import Product
|
||||
|
||||
|
||||
def products(request):
|
||||
protucts = Product.objects.all()
|
||||
return render(request, 'products.html', {'products': protucts})
|
||||
categories = Categories.objects.all()
|
||||
return render(request, 'products.html', {'products': protucts, 'categories': categories})
|
||||
|
||||
|
||||
def createProduct(request):
|
||||
print(request.POST)
|
||||
name = request.POST.get('name')
|
||||
description = request.POST.get('description')
|
||||
price = request.POST.get('price')
|
||||
category = request.POST.get('category')
|
||||
product = Product(name=name, description=description, price=price, category=category)
|
||||
product.save()
|
||||
return redirect('/products')
|
||||
# return render(request, 'products.html')
|
||||
Reference in New Issue
Block a user