Last active
April 18, 2020 18:57
-
-
Save bismarck4lves/6c97ba633e3ce6de490bf3c96e742403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from django.db import models | |
from django.utils import timezone | |
class Setor (models.Model): | |
id = models.AutoField(primary_key=True) | |
nome = models.CharField(max_length=255, unique=True) | |
class Meta: | |
verbose_name_plural = "Setor" | |
def __str__(self): | |
return self.nome | |
class Atendente (models.Model): | |
id = models.AutoField(primary_key=True) | |
nome = models.CharField(max_length=25, unique=True) | |
email = models.EmailField(unique=True) | |
telefone = models.CharField(max_length=255, unique=True) | |
setor = models.ForeignKey( | |
Setor, | |
related_name='setor', | |
on_delete=models.CASCADE | |
) | |
class Meta: | |
verbose_name_plural = "Atendente" | |
def __str__(self): | |
return str(self.nome) | |
class Horas (models.Model): | |
id = models.AutoField(primary_key=True) | |
hora = models.TimeField() | |
status = models.BooleanField(default=True) | |
class Meta: | |
verbose_name_plural = "Horas" | |
def __str__(self): | |
return str(self.hora) | |
class Agendas (models.Model): | |
id = models.AutoField(primary_key=True) | |
atendente = models.ForeignKey( | |
Atendente, | |
related_name='Atendente', | |
on_delete=models.CASCADE | |
) | |
dia = models.DateField() | |
horario = models.ManyToManyField('Horas') | |
class Meta: | |
verbose_name_plural = "Agendas" | |
unique_together = ('dia', 'atendente',) | |
ordering = ['dia'] | |
def __str__(self): | |
return str(self.dia) | |
class Atendimento (models.Model): | |
id = models.AutoField(primary_key=True) | |
agenda = models.ForeignKey( | |
Agendas, | |
related_name='Agendas', | |
on_delete=models.CASCADE | |
) | |
horario = models.ForeignKey( | |
Horas, | |
on_delete=models.CASCADE | |
) | |
data_agendamento = models.DateTimeField( | |
default=timezone.now(), | |
editable=False | |
) | |
user = models.ForeignKey( | |
User, | |
on_delete=models.CASCADE | |
) | |
class Meta: | |
verbose_name_plural = "Atendimento" | |
def __str__(self): | |
return str(self.data_agendamento) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment