From faacd043a02e3d92e94077059fc7df2bf01b396d Mon Sep 17 00:00:00 2001 From: Jean Date: Thu, 28 Nov 2024 21:26:30 -0300 Subject: [PATCH] =?UTF-8?q?Atualiza=C3=A7=C3=B5es=20nos=20aplicativos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web/onibusca/enterprise/models.py | 17 +------ .../enterprise/static/js/formEmpresas.js | 47 ------------------ .../enterprise/templates/formEmpresas.html | 17 ++----- Web/onibusca/enterprise/views.py | 5 ++ Web/onibusca/staticPages/templates/index.html | 25 +++++++++- .../users/__pycache__/views.cpython-312.pyc | Bin 8129 -> 8225 bytes Web/onibusca/users/templates/login.html | 19 +++++++ Web/onibusca/users/views.py | 1 + 8 files changed, 52 insertions(+), 79 deletions(-) delete mode 100644 Web/onibusca/enterprise/static/js/formEmpresas.js diff --git a/Web/onibusca/enterprise/models.py b/Web/onibusca/enterprise/models.py index 8ca0311..8a90316 100644 --- a/Web/onibusca/enterprise/models.py +++ b/Web/onibusca/enterprise/models.py @@ -1,22 +1,7 @@ from django.db import models -# Create your models here. -class Estado(models.Model): - nome = models.CharField(max_length=100) - sigla = models.CharField(max_length=2, unique=True) - - def __str__(self): - return self.sigla - -class Cidade(models.Model): - nome = models.CharField(max_length=28) - estado = models.ForeignKey(Estado, on_delete=models.CASCADE, related_name='cidades') - - class Meta: - unique_together = (('nome', 'estado'),) class Enterprise(models.Model): cnpj = models.CharField(max_length=14, unique=True) nome = models.CharField(max_length=50) - email = models.EmailField(unique=True) - cidades = models.ManyToManyField(Cidade, related_name='empresas') \ No newline at end of file + email = models.EmailField(unique=True) \ No newline at end of file diff --git a/Web/onibusca/enterprise/static/js/formEmpresas.js b/Web/onibusca/enterprise/static/js/formEmpresas.js deleted file mode 100644 index ce30a03..0000000 --- a/Web/onibusca/enterprise/static/js/formEmpresas.js +++ /dev/null @@ -1,47 +0,0 @@ -const adicionarCidade = document.getElementById('adicionarCidade'); - - -let contador = 1; -adicionarCidade.addEventListener('click', function (){ - // Cria span - const spanLinha = document.createElement('span') - spanLinha.id = 'spanLinha'+contador; - spanLinha.className = 'spanLinha' - - // Cria o botão - const btnExcluir = document.createElement('button'); - btnExcluir.className = 'btnExcluir'; - btnExcluir.textContent = 'Excluir'; - btnExcluir.className = 'btnExcluir' - - btnExcluir.addEventListener('click', function () { - document.getElementById('camposCidade').removeChild(spanLinha); - contador--; - atualizarPlaceholders(); - }); - - // Cria input - const novoInput = document.createElement('input') - novoInput.type = 'text'; - novoInput.id = 'cidade'+contador; - novoInput.name = 'cidade'+contador; - novoInput.required = true; - novoInput.placeholder = `${contador+1} ª cidade`; - - // Adiciona os elementos - spanLinha.appendChild(novoInput) - spanLinha.appendChild(btnExcluir); - document.getElementById('camposCidade').appendChild(spanLinha); - - contador++; -}); - -// Atualiza quando remove -function atualizarPlaceholders() { - const inputs = document.querySelectorAll('#camposCidade input'); - inputs.forEach((input, index) => { - input.placeholder = `${index + 1} ª cidade`; - input.id = 'cidade' + (index + 1); - input.name = 'cidade' + (index + 1); - }); -} diff --git a/Web/onibusca/enterprise/templates/formEmpresas.html b/Web/onibusca/enterprise/templates/formEmpresas.html index 0fc591d..bceff58 100644 --- a/Web/onibusca/enterprise/templates/formEmpresas.html +++ b/Web/onibusca/enterprise/templates/formEmpresas.html @@ -4,8 +4,9 @@ - Cadastrar empresa + {% load static %} + @@ -28,7 +29,7 @@
- onibus + onibus
@@ -44,20 +45,8 @@ - -
- -
-
- -
-
- -
- - \ No newline at end of file diff --git a/Web/onibusca/enterprise/views.py b/Web/onibusca/enterprise/views.py index 91ea44a..73e66b9 100644 --- a/Web/onibusca/enterprise/views.py +++ b/Web/onibusca/enterprise/views.py @@ -1,3 +1,8 @@ from django.shortcuts import render # Create your views here. +def cadastro_empresa(request): + if request.method == 'POST': + cnpj = request.POST['cnpj'] + nome = request.POST['nomeEmpresa'] + email = request.POST['emailEmpresa'] \ No newline at end of file diff --git a/Web/onibusca/staticPages/templates/index.html b/Web/onibusca/staticPages/templates/index.html index f54d50a..f04c4d0 100644 --- a/Web/onibusca/staticPages/templates/index.html +++ b/Web/onibusca/staticPages/templates/index.html @@ -19,8 +19,8 @@