| @@ -0,0 +1,74 @@ | ||
| @CHARSET "UTF-8"; | ||
|
|
||
| /* Space out content a bit */ | ||
| body { | ||
| padding-top: 50px; | ||
| padding-bottom: 20px; | ||
| } | ||
|
|
||
| .header, | ||
| .content, | ||
| .footer { | ||
| padding-left: 15px; | ||
| padding-right: 15px; | ||
| } | ||
|
|
||
| .header { | ||
| border-bottom: 1px solid #e5e5e5; | ||
| } | ||
|
|
||
| .header h3 { | ||
| margin-top: 0; | ||
| margin-bottom: 0; | ||
| line-height: 40px; | ||
| padding-bottom: 19px; | ||
| } | ||
|
|
||
| .footer { | ||
| padding-top: 19px; | ||
| color: #777; | ||
| border-top: 1px solid #e5e5e5; | ||
| } | ||
|
|
||
| @media (min-width: 768px) { | ||
| .container { | ||
| max-width: 730px; | ||
| } | ||
| } | ||
| .container-narrow > hr { | ||
| margin: 30px 0; | ||
| } | ||
|
|
||
| .jumbotron { | ||
| text-align: center; | ||
| border-bottom: 1px solid #e5e5e5; | ||
| } | ||
| .jumbotron .btn { | ||
| font-size: 21px; | ||
| padding: 14px 24px; | ||
| } | ||
|
|
||
| .content { | ||
| margin: 40px 0; | ||
| } | ||
| .content p + h4 { | ||
| margin-top: 28px; | ||
| } | ||
|
|
||
| @media screen and (min-width: 768px) { | ||
| /* Remove the padding we set earlier */ | ||
| .header, | ||
| .content, | ||
| .footer { | ||
| padding-left: 0; | ||
| padding-right: 0; | ||
| } | ||
|
|
||
| .header { | ||
| margin-bottom: 30px; | ||
| } | ||
|
|
||
| .jumbotron { | ||
| border-bottom: 0; | ||
| } | ||
| } |
| @@ -0,0 +1,40 @@ | ||
| body { | ||
| padding-top: 40px; | ||
| padding-bottom: 40px; | ||
| background-color: #eee; | ||
| } | ||
|
|
||
| .form-signin { | ||
| max-width: 330px; | ||
| padding: 15px; | ||
| margin: 0 auto; | ||
| } | ||
| .form-signin .form-signin-heading, | ||
| .form-signin .checkbox { | ||
| margin-bottom: 10px; | ||
| } | ||
| .form-signin .checkbox { | ||
| font-weight: normal; | ||
| } | ||
| .form-signin .form-control { | ||
| position: relative; | ||
| font-size: 16px; | ||
| height: auto; | ||
| padding: 10px; | ||
| -webkit-box-sizing: border-box; | ||
| -moz-box-sizing: border-box; | ||
| box-sizing: border-box; | ||
| } | ||
| .form-signin .form-control:focus { | ||
| z-index: 2; | ||
| } | ||
| .form-signin input[type="text"] { | ||
| margin-bottom: -1px; | ||
| border-bottom-left-radius: 0; | ||
| border-bottom-right-radius: 0; | ||
| } | ||
| .form-signin input[type="password"] { | ||
| margin-bottom: 10px; | ||
| border-top-left-radius: 0; | ||
| border-top-right-radius: 0; | ||
| } |
| @@ -0,0 +1,54 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="pt-br"> | ||
| {% load staticfiles %} | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>eAdopt</title> | ||
| <link rel="stylesheet" href="{% static 'styles/bootstrap.css' %}"> | ||
| <link rel="stylesheet" href="{% static 'styles/main.css' %}"> | ||
| <link rel="stylesheet" href="{% static 'styles/signin.css' %}"> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
| <header> | ||
| <nav class="navbar navbar-default navbar-fixed-top navbar-inverse"> | ||
| <div class="container"> | ||
| <div class="navbar-header"> | ||
| <a class="navbar-brand" href="/">eAdopt</a> | ||
| </div> | ||
| <ul class="nav navbar-nav navbar-right"> | ||
| {% if 'usuario_id' in request.session %} | ||
| <li> | ||
| <a href="{# {% url 'usuario_editar' %} #}">Editar Perfil</a> | ||
| </li> | ||
| <li> | ||
| <a href="{% url 'usuario_logout' %}">Sair</a> | ||
| </li> | ||
| {% else %} | ||
| <li> | ||
| <a href="{% url 'usuario_novo' %}">Registre-se</a> | ||
| </li> | ||
| {% endif %} | ||
| </ul> | ||
| </div> | ||
| </nav> | ||
| </header> | ||
|
|
||
| <main> | ||
| <div class="container"> | ||
| {% if messages %} | ||
| <ul class="messages"> | ||
| {% for message in messages %} | ||
| <li{% if message.tags %} class="alert alert-{{ message.tags }}"{% endif %}>{{ message }}</li> | ||
| {% endfor %} | ||
| </ul> | ||
| {% endif %} | ||
|
|
||
| {% block content %} | ||
| {% endblock %} | ||
| </div> | ||
| </main> | ||
|
|
||
| </body> | ||
| </html> |
| @@ -0,0 +1,73 @@ | ||
| # Generated by Django 2.0.3 on 2018-06-16 23:04 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('usuarios', '0001_initial'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='pf', | ||
| name='data_nascimento', | ||
| field=models.DateField(blank=True, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='bairro', | ||
| field=models.CharField(blank=True, max_length=80, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='cep', | ||
| field=models.CharField(blank=True, max_length=80, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='cidade', | ||
| field=models.CharField(blank=True, max_length=80, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='estado', | ||
| field=models.CharField(blank=True, max_length=80, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='id_mongo', | ||
| field=models.CharField(blank=True, max_length=24, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='latitude', | ||
| field=models.FloatField(blank=True, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='longitude', | ||
| field=models.FloatField(blank=True, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='rua', | ||
| field=models.CharField(blank=True, max_length=80, null=True), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='usuario', | ||
| name='telefone', | ||
| field=models.CharField(blank=True, max_length=80, null=True), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='pf', | ||
| name='cpf', | ||
| field=models.CharField(max_length=11, unique=True), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='pj', | ||
| name='cnpj', | ||
| field=models.CharField(max_length=14, unique=True), | ||
| ), | ||
| ] |
| @@ -0,0 +1,18 @@ | ||
| # Generated by Django 2.0.3 on 2018-06-16 23:09 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('usuarios', '0002_auto_20180616_2004'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='usuario', | ||
| name='cep', | ||
| field=models.CharField(blank=True, max_length=8, null=True), | ||
| ), | ||
| ] |
| @@ -0,0 +1,23 @@ | ||
| # Generated by Django 2.0.3 on 2018-06-16 23:10 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('usuarios', '0003_auto_20180616_2009'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='usuario', | ||
| name='estado', | ||
| field=models.CharField(blank=True, max_length=2, null=True), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='usuario', | ||
| name='telefone', | ||
| field=models.CharField(blank=True, max_length=11, null=True), | ||
| ), | ||
| ] |
| @@ -0,0 +1,18 @@ | ||
| # Generated by Django 2.0.3 on 2018-06-17 00:00 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('usuarios', '0004_auto_20180616_2010'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='usuario', | ||
| name='email', | ||
| field=models.CharField(max_length=80, unique=True), | ||
| ), | ||
| ] |
| @@ -1,12 +1,22 @@ | ||
| from django.db import models | ||
|
|
||
| class Usuario(models.Model): | ||
| email = models.CharField(max_length=80, null=False, blank=False, unique=True) | ||
| senha = models.CharField(max_length=20, null=False, blank=False) | ||
| nome = models.CharField(max_length=80, null=False, blank=False) | ||
| rua = models.CharField(max_length=80, null=True, blank=True) | ||
| bairro = models.CharField(max_length=80, null=True, blank=True) | ||
| cidade = models.CharField(max_length=80, null=True, blank=True) | ||
| estado = models.CharField(max_length=2, null=True, blank=True) | ||
| cep = models.CharField(max_length=8, null=True, blank=True) | ||
| telefone = models.CharField(max_length=11, null=True, blank=True) | ||
| latitude = models.FloatField(null=True, blank=True) | ||
| longitude = models.FloatField(null=True, blank=True) | ||
| id_mongo = models.CharField(max_length=24, null=True, blank=True) | ||
|
|
||
| class PF(Usuario): | ||
| cpf = models.CharField(max_length=11, unique=True) | ||
| data_nascimento = models.DateField(null=True, blank=True) | ||
|
|
||
| class PJ(Usuario): | ||
| cnpj = models.CharField(max_length=14, unique=True) |
| @@ -0,0 +1,11 @@ | ||
| {% extends 'base.html' %} | ||
| {% block content %} | ||
|
|
||
| <div class="panel panel-default"> | ||
| <div class="panel-heading"><strong>Home</strong></div> | ||
| <div class="panel-body"> | ||
| bem-vindo panguá | ||
| </div> | ||
| </div> | ||
|
|
||
| {% endblock %} |
| @@ -1 +1,25 @@ | ||
| {% extends 'base.html' %} | ||
| {% block content %} | ||
|
|
||
| <div class="panel panel-default"> | ||
| <div class="panel-heading"><strong>Login</strong></div> | ||
| <div class="panel-body"> | ||
| <form class="form-signin" action="{% url 'usuario_entrar' %}" method="post"> | ||
| {% csrf_token %} | ||
|
|
||
| <p> | ||
| E-mail: <br> | ||
| <input type="text" name="email"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Senha: <br> | ||
| <input type="password" name="senha"> | ||
| </p> | ||
|
|
||
| <p><input type="submit" value="Entrar" class="btn btn-primary"/></p> | ||
| </form> | ||
| </div> | ||
| </div> | ||
|
|
||
| {% endblock %} |
| @@ -0,0 +1,88 @@ | ||
| {% extends 'base.html' %} | ||
| {% block content %} | ||
|
|
||
| <div class="panel panel-default"> | ||
| <div class="panel-heading"><strong>Registro</strong></div> | ||
| <div class="panel-body"> | ||
| <form class="form-signin" action="{% url 'usuario_criar' %}" method="post"> | ||
| {% csrf_token %} | ||
|
|
||
| <p> | ||
| Nome: <br> | ||
| <input type="text" name="nome" maxlength="80"> | ||
| </p> | ||
|
|
||
| <p> | ||
| E-mail: <br> | ||
| <input type="text" name="email" maxlength="80"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Senha: <br> | ||
| <input type="password" name="senha" maxlength="20"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Rua: <br> | ||
| <input type="text" name="rua" maxlength="80"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Bairro: <br> | ||
| <input type="text" name="bairro" maxlength="80"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Cidade: <br> | ||
| <input type="text" name="cidade" maxlength="80"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Estado: <br> | ||
| <input type="text" name="estado" maxlength="2"> | ||
| </p> | ||
|
|
||
| <p> | ||
| CEP: <br> | ||
| <input type="text" name="cep" maxlength="8"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Telefone: <br> | ||
| <input type="text" name="telefone" maxlength="11"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Lat.: <input type="number" name="latitude"> / | ||
| Long: <input type="number" name="longitude"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Tipo: <br> | ||
| <select name="tipo"> | ||
| <option value="pf">Pessoa física</option> | ||
| <option value="pj">Pessoa jurídica</option> | ||
| </select> | ||
| </p> | ||
|
|
||
| <p> | ||
| CPF: <br> | ||
| <input type="text" name="cpf" maxlength="11"> | ||
| </p> | ||
|
|
||
| <p> | ||
| Data de nascimento: <br> | ||
| <input type="date" name="data_nascimento"> | ||
| </p> | ||
|
|
||
| <p> | ||
| CNPJ: <br> | ||
| <input type="text" name="cnpj" maxlength="14"> | ||
| </p> | ||
|
|
||
| <p><input type="submit" value="Cadastrar" class="btn btn-primary"/></p> | ||
| </form> | ||
| </div> | ||
| </div> | ||
|
|
||
| {% endblock %} |
| @@ -1,7 +1,14 @@ | ||
| from django.conf.urls import url | ||
|
|
||
| from . import views | ||
|
|
||
| urlpatterns = [ | ||
| url(r'^login/$', views.login, name='usuario_login'), | ||
| url(r'^entrar/$', views.entrar, name='usuario_entrar'), | ||
| url(r'^logout/$', views.logout, name='usuario_logout'), | ||
| url(r'^novo/$', views.novo, name='usuario_novo'), | ||
| url(r'^criar/$', views.criar, name='usuario_criar'), | ||
| #url(r'^editar/$', views.editar, name='usuario_editar'), | ||
| #url(r'^atualizar/$', views.update, name='usuario_update'), | ||
| #url(r'^remover/$', views.delete, name='usuario_remover') | ||
| ] |
| @@ -1,4 +1,60 @@ | ||
| from django.shortcuts import render | ||
| from usuarios.models import Usuario, PF, PJ | ||
| from django.contrib import messages | ||
| from django.shortcuts import render, redirect | ||
|
|
||
| def login(request): | ||
| return render(request, 'login.html') | ||
|
|
||
|
|
||
| def entrar(request): | ||
| mensagem = 'E-mail ou senha inválidos. Verifique os dados e tente novamente.' | ||
| try: | ||
| usuario_existente = Usuario.objects.get(email=request.POST['email']) | ||
| if usuario_existente.email == request.POST['email'] and usuario_existente.senha == request.POST['senha']: | ||
| request.session['usuario_id'] = usuario_existente.id | ||
| return redirect('index') | ||
| else: | ||
| messages.warning(request, mensagem) | ||
| except Usuario.DoesNotExist: | ||
| messages.warning(request, mensagem) | ||
| return redirect('usuario_login') | ||
|
|
||
|
|
||
| def index(request): | ||
| return render(request, 'index.html') | ||
|
|
||
|
|
||
| def logout(request): | ||
| request.session.flush() | ||
| return redirect('usuario_login') | ||
|
|
||
|
|
||
| def novo(request): | ||
| return render(request, 'novo.html') | ||
|
|
||
|
|
||
| def criar(request): | ||
| if request.POST['tipo'] == 'pf': | ||
| novo_usuario = PF() | ||
| novo_usuario.cpf = request.POST['cpf'] | ||
| novo_usuario.data_nascimento = request.POST['data_nascimento'] | ||
| else: | ||
| novo_usuario = PJ() | ||
| novo_usuario.cnpj = request.POST['cnpj'] | ||
|
|
||
| novo_usuario.nome = request.POST['nome'] | ||
| novo_usuario.email = request.POST['email'] | ||
| novo_usuario.senha = request.POST['senha'] | ||
| novo_usuario.rua = request.POST['rua'] | ||
| novo_usuario.bairro = request.POST['bairro'] | ||
| novo_usuario.cidade = request.POST['cidade'] | ||
| novo_usuario.estado = request.POST['estado'] | ||
| novo_usuario.cep = request.POST['cep'] | ||
| novo_usuario.telefone = request.POST['telefone'] | ||
| novo_usuario.latitude = request.POST['latitude'] | ||
| novo_usuario.longitude = request.POST['longitude'] | ||
|
|
||
| novo_usuario.save() | ||
| request.session['usuario_id'] = novo_usuario.id | ||
| return redirect('index') |