Skip to content

Commit

Permalink
Merge pull request #17 from Wooo589/Jose
Browse files Browse the repository at this point in the history
Jose
  • Loading branch information
JAugusto-Moraes authored Oct 31, 2023
2 parents 13f43f8 + 4e9daf5 commit 748fd9b
Show file tree
Hide file tree
Showing 16 changed files with 151 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# End of https://www.toptal.com/developers/gitignore/api/django
# End of https://www.toptal.com/developers/gitignore/api/django
*.pyc
2 changes: 1 addition & 1 deletion inicial/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from .models import Hospital, Avaliacao
from .models import *

class ListandoHospitais(admin.ModelAdmin):
list_display = ("cnes", "nome", "uf", "categoria")
Expand Down
3 changes: 3 additions & 0 deletions inicial/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ class InicialConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'inicial'
verbose_name = "MedConnect"

def ready(self):
import inicial.signals
49 changes: 47 additions & 2 deletions inicial/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from .models import Hospital
from .models import *

class BuscarForms(forms.Form):
buscar = forms.CharField(
Expand Down Expand Up @@ -100,4 +100,49 @@ class AvaliarForms(forms.Form):
"id":"horario-atendimento",
"type": "datetime-local"
}
))
))

class CadastroForms(forms.Form):
email = forms.EmailField(
label="E-mail",
required=True,
max_length=100,
widget=forms.TextInput(
attrs={
"placeholder":"Digite seu e-mail"
}
)
)

nome_cadastro = forms.CharField(
label="Usuário",
required=True,
max_length=100,
widget=forms.TextInput(
attrs={
"placeholder": "Digite seu nome de usuário"
}
)
)

senha_1 = forms.CharField(
label="Senha",
required=True,
max_length=70,
widget=forms.PasswordInput(
attrs={
"placeholder": "Digite sua senha"
}
)
)

senha_2 = forms.CharField(
label="Confirme sua senha",
required=True,
max_length=70,
widget=forms.PasswordInput(
attrs={
"placeholder": "Confirme sua senha"
}
)
)
2 changes: 1 addition & 1 deletion inicial/management/commands/importcsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def handle(self, *args, **options):
df = pd.read_csv(options['path'])
df = df.fillna('')

if options['uf']:
if options['uf'] != '*':
df = df[df["UF"] == options['uf']]
df = df.reset_index(drop=True)

Expand Down
10 changes: 8 additions & 2 deletions inicial/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.utils import timezone
from datetime import date, timedelta

class Hospital(models.Model):
Expand Down Expand Up @@ -48,10 +49,15 @@ class Hospital(models.Model):
municipio = models.CharField(max_length=150, default='')
telefone = models.CharField(max_length=100, null=False, blank=False, default="Não informado")
email = models.CharField(max_length=100, null=False, blank=False, default="Não informado")
tempo_emergente = models.IntegerField(null=False, blank=False, default=0)
tempo_muito_urgente = models.IntegerField(null=False, blank=False, default=0)
tempo_urgente = models.IntegerField(null=False, blank=False, default=0)
tempo_pouco_urgente = models.IntegerField(null=False, blank=False, default=0)
tempo_nao_urgente = models.IntegerField(null=False, blank=False, default=0)

def __str__(self):
return self.nome

class Avaliacao(models.Model):

ATENDIMENTO = [
Expand All @@ -68,7 +74,7 @@ class Avaliacao(models.Model):
]

usuario = models.CharField(max_length=100, null=False, blank=False, default="")
data = models.DateField(null=False, blank=False, default=date.today())
data = models.DateField(null=False, blank=False, default=timezone.now)
hospital = models.ForeignKey(Hospital, on_delete=models.CASCADE)
atendimento = models.CharField(max_length=100, null=False, blank=False, default="SIM", choices=ATENDIMENTO)
risco = models.CharField(max_length=100, null=False, blank=False, default="NAO_URGENTE", choices=RISCO)
Expand Down
33 changes: 33 additions & 0 deletions inicial/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
from django.db.models import Avg
from .models import *
from datetime import timedelta

@receiver(post_save, sender=Avaliacao)
def update_time(sender, instance, created, **kwargs):
if created:
hospital = instance.hospital
risco = instance.risco
duracao = Avaliacao.objects.filter(hospital=hospital).filter(risco=risco).aggregate(Avg("duracao", default=timedelta(minutes=0)))
minutos = round(duracao["duracao__avg"].seconds / 60)

if risco == "EMERGENTE":
hospital.tempo_emergente = minutos
hospital.save()

if risco == "MUITO_URGENTE":
hospital.tempo_muito_urgente = minutos
hospital.save()

if risco == "URGENTE":
hospital.tempo_urgente = minutos
hospital.save()

if risco == "POUCO_URGENTE":
hospital.tempo_pouco_urgente = minutos
hospital.save()

if risco == "NAO_URGENTE":
hospital.tempo_nao_urgente = minutos
hospital.save()
2 changes: 1 addition & 1 deletion inicial/static/css_criarconta_2.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}

body{
background-image:url("{% static 'img/bg_criarconta.jpg' %}");
background-image:url('img/bg_criarconta.jpg');
background-size:cover;
}

Expand Down
32 changes: 30 additions & 2 deletions inicial/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def buscar(request):
hospitais = Hospital.objects.order_by("nome")
buscar2 = BuscarForms()
filter_form = FilterForms()
user = request.user

if "uf" in request.GET:
uf_a_buscar = request.GET['uf']
Expand Down Expand Up @@ -73,6 +72,7 @@ def avaliar_hospital(request, hospital_cnes):
observacao = request.POST["observacao"]

Avaliacao.objects.create(
usuario=request.user.username,
hospital=hospital,
risco=risco,
duracao=duracao,
Expand All @@ -91,7 +91,35 @@ def duvidas_frequentes(request):
return render(request, 'inicial/duvidas_frequentes.html')

def cadastro(request):
return render(request, 'inicial/criar_conta_2.html')

cadastro = CadastroForms()

if request.method == "POST":
cadastro = CadastroForms(request.POST)

if cadastro.is_valid():
if cadastro["senha_1"].value() != cadastro["senha_2"].value():
return redirect('cadastro')

nome = cadastro["nome_cadastro"].value()
email = cadastro["email"].value()
senha = cadastro["senha_1"].value()

if User.objects.filter(username=nome).exists():
redirect('cadastro')

usuario = User.objects.create_user(
username=nome,
email=email,
password=senha
)

usuario.save()
return redirect('login')

context = {"cadastro":cadastro}

return render(request, 'inicial/criar_conta_2.html', context)

def loginsite(request):

Expand Down
Binary file modified setup/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file modified setup/__pycache__/urls.cpython-311.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion templates/inicial/FazerLogin.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 class="titule"> Fazer login</h1>
<a style="text-decoration: none" href="{% url "cadastro" %}"><p class="CriarConta" >Criar conta</p></a>
<form action="{% url "login" %}" method="POST">
{% csrf_token %}
<input name="email" class="email_login" style="display: block;" type="email" placeholder="EMAIL">
<input name="email" class="email_login" style="display: block;" type="text" placeholder="USUÁRIO">
<input name="senha" class="password_login" style="display: block;" type="password" placeholder="SENHA">
<a style="text-decoration: none;" href="{% url "esqueci_senha" %}"><p class="link_esqueciSenha">esqueci a senha</p></a>
<button style="display: block;" type="submit" id="button_login">REALIZAR LOGIN</button>
Expand Down
8 changes: 4 additions & 4 deletions templates/inicial/avaliarhospital.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ <h3><strong>{{ hospital.nome }}</strong></h3>
<div class="tempos_de_espera">
<div class="tempos">
<span class="c-orange"></span>
<span>x min</span>
<span>{{ hospital.tempo_muito_urgente}} min</span>
</div>
<div class="tempos">
<span class="c-yellow"></span>
<span>x min</span>
<span>{{ hospital.tempo_urgente }} min</span>
</div>
<div class="tempos">
<span class="c-green"></span>
<span>x min</span>
<span>{{ hospital.tempo_pouco_urgente }} min</span>
</div>
<div class="tempos">
<span class="c-blue"></span>
<span>x min</span>
<span>{{ hospital.tempo_nao_urgente }} min</span>
</div>
</div>
</div>
Expand Down
22 changes: 10 additions & 12 deletions templates/inicial/criar_conta_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<span class="form-stepper-circle">
<span>1</span>
</span>
<div class="label">Dados pessoais</div>
<div class="label">Informações Básicas</div>
</a>
</li>
<!--etapa 2-->
Expand All @@ -28,7 +28,7 @@
<span class="form-stepper-circle text-muted">
<span>2</span>
</span>
<div class="label text-muted">Social profiles</div>
<div class="label text-muted">Conclusão</div>
</a>
</li>

Expand All @@ -44,18 +44,16 @@
<p><input placeholder="Digite sua senha" oninput="this.className = ''"></p>
</div>-->
<section id="step-1" class="form-step">
<h2 class="font-normal">Account Basic Details</h2>
<h2 class="font-normal">Informações Básicas</h2>
<!--campos de input do passo 1-->
<div class="mt-3">
<!--Vão aqui os campos de input..-->
<img src="https://electricwoodlands.com/wp-content/uploads/2021/06/Google_NoHover.png" style="width:60%;height:auto;">
<img src="https://electricwoodlands.com/wp-content/uploads/2021/06/FB_NoHover.png" style="width:60%;height:auto;">
<label for="email"><b><br>E-mail</b></label>
<input type="text" placeholder="Digite seu e-mail" name="email" required>
<label for="psw"><b><br>Senha</b></label>
<input type="password" placeholder="Digite sua senha" name="senha" required>
<label for="psw-repeat"><br><b>Confirme sua senha</b></label>
<input type="password" placeholder="Confirme sua senha" name="senha2" required>
<!--<img src="https://electricwoodlands.com/wp-content/uploads/2021/06/Google_NoHover.png" style="width:60%;height:auto;">
<img src="https://electricwoodlands.com/wp-content/uploads/2021/06/FB_NoHover.png" style="width:60%;height:auto;">-->
{% for field in cadastro.visible_fields %}
<label for="{{ field.id_for_label }}"><b><br>{{ field.label }}</b></label>
{{ field }}
{% endfor %}
</div>
<div class="mt-3">
<button class="button btn-navigate-form-step" type="button" step_number="2">Próximo</button>
Expand All @@ -75,7 +73,7 @@ <h2 class="font-normal">Social profiles</h2>
</div>
<div class="mt-3">
<button class="button btn-navigate-form-step" type="button" step_number="1">Anterior</button>
<button class="button submit-btn" type="submit">Enviar</button>
<button class="button submit-btn" type="submit">Concluir cadastro</button>
</div>
</section>

Expand Down
12 changes: 6 additions & 6 deletions templates/inicial/locaisdeatendimento.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
<script src="{% static "js/select.js"%}"></script>
<script src="{% static 'js/script-select-menu-e-login-box.js'%}"></script>
</head>
<body>
<!-- MENU SUPERIOR -->
Expand Down Expand Up @@ -174,19 +175,19 @@ <h3><strong>{{ hospital.nome }}</strong></h3>
<div class="tempos_de_espera">
<div class="tempos">
<span class="c-orange"></span>
<span>x min</span>
<span>{{ hospital.tempo_muito_urgente}} min</span>
</div>
<div class="tempos">
<span class="c-yellow"></span>
<span>x min</span>
<span>{{ hospital.tempo_urgente }} min</span>
</div>
<div class="tempos">
<span class="c-green"></span>
<span>x min</span>
<span>{{ hospital.tempo_pouco_urgente }} min</span>
</div>
<div class="tempos">
<span class="c-blue"></span>
<span>x min</span>
<span>{{ hospital.tempo_nao_urgente }} min</span>
</div>
</div>
<button class="info"><a href="{% url "mais_informacoes" hospital.cnes %}"><span style="font-size: 22px;">+</span><span> INFORMAÇÕES</span></a></button>
Expand All @@ -195,8 +196,7 @@ <h3><strong>{{ hospital.nome }}</strong></h3>
{% endfor %}
</ul>
</section>
</main>
<script src="{% static 'js/script-select-menu-e-login-box.js'%}"></script>
</main>
<footer>
<p>©MedConnect 2023</p>
<p>Site criado por feudo 9 - "Verde Pântano".</p>
Expand Down
8 changes: 4 additions & 4 deletions templates/inicial/maisinformacoes.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ <h3><strong>{{ hospital.nome }}</strong></h3>
<div class="tempos_de_espera">
<div class="tempos">
<span class="c-orange"></span>
<span>x min</span>
<span>{{ hospital.tempo_muito_urgente}} min</span>
</div>
<div class="tempos">
<span class="c-yellow"></span>
<span>x min</span>
<span>{{ hospital.tempo_urgente }} min</span>
</div>
<div class="tempos">
<span class="c-green"></span>
<span>x min</span>
<span>{{ hospital.tempo_pouco_urgente }} min</span>
</div>
<div class="tempos">
<span class="c-blue"></span>
<span>x min</span>
<span>{{ hospital.tempo_nao_urgente }} min</span>
</div>
</div>
</div>
Expand Down

0 comments on commit 748fd9b

Please sign in to comment.