Example #1
0
class Pessoa(models.Model):
    cpf = CPFField(unique=True, primary_key=True)
    nome = models.CharField(max_length=80, null=True, blank=False)
    email = models.EmailField(blank=True, null=True)

    def __str__(self):
        return self.cpf + ' ' + self.nome
Example #2
0
class Dados_usuario(models.Model):

    cpf = cpf = CPFField('cpf', null=True, blank=True)
    nome = models.CharField(null=True, blank=True, max_length=255)
    sobrenome = models.CharField(null=True, blank=True, max_length=255)
    data_nascimento = models.DateField(null=True,
                                       blank=True,
                                       verbose_name='Data de Nascimento')
    telefone = models.CharField(null=True, blank=True, max_length=12)
    cep = models.CharField(null=True, blank=True, max_length=10, unique=True)
    cidade = models.CharField(null=True, blank=True, max_length=255)
    estado = models.CharField(null=True, blank=True, max_length=2)
    rua = models.CharField(null=True, blank=True, max_length=255)
    bairro = models.CharField(null=True, blank=True, max_length=255)
    complemento = models.CharField(null=True, blank=True, max_length=255)
    user = models.OneToOneField(MyUser,
                                null=True,
                                blank=True,
                                on_delete=models.CASCADE)
    foto = models.ImageField(null=True, blank=True, verbose_name="Imagem")

    def __str__(self):
        return self.nome

    @property
    def get_photo_url(self):
        if self.foto and hasattr(self.foto, 'url'):
            return self.foto.url
        else:
            return "/static/images/user.png"
Example #3
0
class Pessoa(FollowUserModel):
    user = models.ForeignKey(User,
                             on_delete=models.CASCADE,
                             verbose_name='Usuário')
    acesso = models.IntegerField(choices=ACESSO_CHOICES,
                                 null=True,
                                 blank=True,
                                 verbose_name="Tipo de Acesso")
    nome = models.CharField(max_length=255, verbose_name="Nome")
    data_nascimento = models.DateField(verbose_name="Data de Nascimento")
    cpf = CPFField(verbose_name="CPF")
    email = models.EmailField(verbose_name="Email")
    whats = models.CharField(max_length=15, verbose_name="WhatsApp")
    setor = models.ForeignKey(Setor,
                              on_delete=models.CASCADE,
                              verbose_name='Setor')
    slug = models.SlugField(max_length=255, unique=True, verbose_name="Slug")

    def save(self, *args, **kwargs):
        is_new = self.pk is None
        if is_new:
            super(Pessoa, self).save()
            self.slug = uuid.uuid4()

        super(Pessoa, self).save(*args, **kwargs)

    def __str__(self):
        return self.nome

    def get_absolute_url(self):
        return reverse('events.views.details', args=[str(self.id)])

    class Meta:
        verbose_name_plural = 'Pessoas'
        db_table = u'pessoa'
Example #4
0
class User(AbstractUser):

    username_validator = UnicodeUsernameValidator()

    username = None
    name = models.CharField(
        max_length=150,
        unique=True,
        validators=[username_validator],
        error_messages={
            'unique': "A user with that name already exists.",
        },
    )
    birthday = models.DateField(default=timezone.now, null=True, blank=True)
    cpf = CPFField('cpf')
    cep = models.CharField(max_length=9, null=True, blank=True)
    street = models.CharField(max_length=100, null=True, blank=True)
    neighborhood = models.CharField(max_length=100, null=True, blank=True)
    city = models.CharField(max_length=50, null=True, blank=True)
    state = models.CharField(max_length=50, null=True, blank=True)

    USERNAME_FIELD = 'name'
    REQUIRED_FIELDS = []

    objects = UserManager()

    class Meta:
        verbose_name = 'user'
        verbose_name_plural = 'users'

    def __str__(self):
        return self.name
Example #5
0
class Post(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)

    Exames = (('Covid-19', 'Covid-19'), ('Leishmaniose', 'Leishmaniose'))
    sexo_escolha = (
        ('Masculino', 'Masculino'),
        ('Feminino', 'Feminino'),
        ('Outros', 'Outros'),
    )

    Exame = models.CharField(max_length=20, choices=Exames)
    Nome_do_paciente = models.CharField(max_length=50)
    Cpf_paciente = CPFField('cpf')
    Sexo = models.CharField(max_length=20, choices=sexo_escolha)
    Data_de_nascimento = models.DateField()
    created_date = models.DateTimeField(default=timezone.now)
    published_date = models.DateTimeField(blank=True, null=True)
    four_digit_code = models.IntegerField(blank=False, null=True)
    author = models.TextField()

    def publish(self):
        self.published_date = timezone.now()
        self.save()

    def __str__(self):
        return self.Exame
Example #6
0
class Visitante(models.Model):
    nome = models.CharField(max_length=150, help_text="Nome do Visitante")
    cpf = CPFField('cpf')
    #endereco
    #cep
    #telefone
    #email
Example #7
0
class Client(models.Model):
    name = models.CharField(max_length=200)
    cpf = CPFField('cpf', unique=True)
    birth = models.DateTimeField()

    def __str__(self):
        return self.name
Example #8
0
class SolicitacaoEducacao(models.Model):
    email = models.ForeignKey(ProfileUser, on_delete=models.CASCADE)
    cadastro_pf = CPFField('CPF')
    rg = models.CharField(max_length=15, validators=[only_int])
    data_criacao = models.DateTimeField(default=timezone.now)
    escola = models.CharField(max_length=100)

    def __str__(self):
        return self.email
Example #9
0
class Farmer(models.Model):
    cpf = CPFField('cpf', null=False, unique=True)
    email = models.EmailField(null=False)
    name = models.CharField(null=False, max_length=255)

    class Meta:
        db_table = 'farmer'

    def __str__(self):
        return self.name
Example #10
0
class Cliente(models.Model):
    nome = models.CharField(max_length=255, blank=False, null=False, verbose_name='Nome completo')
    cpf = CPFField('CPF')
    email_cliente = models.EmailField(blank=True, null=True, verbose_name='E-mail')
    fk_endereco = models.ManyToManyField('Endereco', verbose_name='Nome da rua e número da casa')

    def Nome_e_numero_da_casa(self):
        return ",".join([str(p) for p in self.fk_endereco.all()])

    def __str__(self):
        return self.nome
Example #11
0
class Cliente(models.Model):
    cpf = CPFField(primary_key=True)
    nome = models.CharField(max_length=200)
    telefone = models.CharField(max_length=11)
    cidade = models.CharField(max_length=200)
    estado = models.CharField(max_length=100)
    endereco = models.CharField(max_length=200)
    numero = models.CharField(max_length=5)
    cep = models.CharField(max_length=8)
    
    def __str__(self):
        return self.nome
Example #12
0
class Funcionario(models.Model):
    nome_funcionario = models.CharField(max_length=255, blank=False, null=False, verbose_name='Nome completo')
    cpf_funcionario = CPFField('CPF')
    email_funcionario = models.EmailField(blank=True, null=True, verbose_name='E-mail')
    codigo_de_contrato = models.CharField(max_length=11, blank=False, null=False, verbose_name='Código do contrato')
    fk_funcao = models.ForeignKey('Funcao', on_delete=models.DO_NOTHING, default=1, verbose_name='Cargo')
    Sim = 'Sim'
    Nao = 'Não'
    status_choices = [
        ( Sim, 'SIM'),
        ( Nao, 'NÃO')
    ]
    status = models.CharField(choices=status_choices, max_length=3, verbose_name='Empregado')
class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    cpf = CPFField('cpf')
    account = models.CharField(max_length=100, null=True, blank=True)
    balance = models.DecimalField(max_digits=10,
                                  decimal_places=2,
                                  null=True,
                                  blank=True)
    cellphone = models.CharField(max_length=12, null=True, blank=True)
    address = models.ForeignKey(AddressStreet, on_delete=models.CASCADE)

    class Meta:
        verbose_name = u'pessoa'
        verbose_name_plural = u'pessoas'
Example #14
0
class Cliente(models.Model):
    nome = models.CharField('Nome Completo', max_length=100)
    cpf = CPFField('Cpf')
    data_nascimento = models.DateField('Data de nascimento')
    email = models.EmailField()
    endereço = models.CharField(max_length=200)
    cidade = models.CharField(max_length=200)
    celular = models.CharField(max_length=12)
    curso = models.CharField(max_length=50, blank=True)
    observações = models.TextField('Observações', blank=True)
    start_date = models.DateTimeField('start date', auto_now_add=True)

    def __str__(self):
        return self.nome
Example #15
0
class Pessoa(models.Model):
    SEXO_CHOICES = (
        (u'Masculino', u'Masculino'),
        (u'Feminino', u'Feminino'),
    )
    nome = models.CharField(max_length=255)
    cpf = CPFField('CPF')
    data_de_nascimento = models.DateField()
    phone = PhoneField(blank=True, help_text='Contact phone number')
    sexo = models.CharField(max_length=9, null=False, choices=SEXO_CHOICES)
    data = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.nome
Example #16
0
class Cliente(AbstractUser):
    email = models.EmailField('email', unique=True, max_length=254)
    telefone = models.CharField('telefone', max_length=15)
    endereco = models.CharField('endereco', max_length=50)
    cpf = CPFField(null=True)
    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['first_name']

    def __str__(self):
        return self.email

    # def retorna_usuario (self, id):
    #     return Cliente.objects.all()

    objects = ClienteManager()
Example #17
0
class Tb_usuario(models.Model):
    nome = models.CharField(max_length=100, verbose_name='Nome')
    cpf = CPFField('cpf')
    cep = BRPostalCodeField(null=True, verbose_name='Cep')
    endereco = models.CharField(max_length=200, verbose_name='Endereço')
    email = models.EmailField()
    telefone = PhoneField(blank=True, help_text='Contact phone number')
    dt_nascimento = models.DateField(verbose_name='Data de nascimento')

    class Meta:
        ordering = ('nome', )
        verbose_name = 'Usuario'
        verbose_name_plural = 'Usuarios'

    def __str__(self):
        return self.nome
Example #18
0
class Tb_cliente(models.Model):
    nome = models.CharField(max_length=100, verbose_name='Nome')
    cpf = CPFField('cpf')
    cep = BRPostalCodeField(null=True, verbose_name='Cep')
    endereco = models.CharField(max_length=200, verbose_name='Endereço')
    bairro = models.CharField(max_length=50, verbose_name='Bairro')
    uf = models.CharField(max_length=2, verbose_name='Uf')
    dt_nascimento = models.DateField(verbose_name='Data de nascimento')

    class Meta:
        ordering = ('nome', )
        verbose_name = 'Cliente'
        verbose_name_plural = 'Clientes'

    def __str__(self):
        return self.nome
Example #19
0
class Usuario(AbstractUser):
    email = models.EmailField('E-mail', unique=True)
    data_nascimento = models.DateField(null=True, blank=True)
    celular = models.CharField(max_length=50, null=True, blank=True)
    cpf = CPFField('cpf')
    is_staff = models.BooleanField('Membro da equipe', default=True)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['first_name', 'last_name']

    def __str__(self):
        return self.email

    class Meta:
        db_table = "usuario"

    objects = UsuarioManager()
Example #20
0
class WhiteListPedido(models.Model):
    class Meta:
        verbose_name = u'White List Pedido'
        verbose_name_plural = u'White List Pedido'
        db_table = 'white_list_pedido'
        ordering = ['cpf']

    cpf = CPFField('cpf', unique=True)
    ativo = BooleanField(verbose_name=u'Ativo?',
                         default=True,
                         null=False,
                         blank=False)

    def __str__(self):
        return self.cpf

    def __unicode__(self):
        return u'%s' % (self.cpf)
Example #21
0
class Revendedor(models.Model):
    class Meta:
        verbose_name = u'Revendedor'
        verbose_name_plural = u'Revendedores'
        db_table = 'revendedor'
        ordering = ['nome']

    nome = models.CharField(max_length=60, verbose_name=u'Nome')
    cpf = CPFField('cpf', unique=True)
    email = models.EmailField(max_length=60,
                              verbose_name=u'Email',
                              unique=True)
    senha = models.CharField(max_length=100, verbose_name=u'Senha')

    def __str__(self):
        return self.nome

    def __unicode__(self):
        return u'%s' % self.nome
Example #22
0
class Cliente(models.Model):
    '''
    Model que representa o Cliente que será cadastrado
    '''
    id = models.AutoField(primary_key=True, unique=True)
    nome = models.CharField(max_length=100)
    email = models.EmailField(unique=True)
    telefone = models.CharField(max_length=11, unique=True)
    cpf = CPFField(unique=True)
    data_cadastro = models.DateField(auto_now_add=True)
    imagem = models.ImageField(upload_to=upload_imagem_cliente,
                               blank=True,
                               null=True)

    def __str__(self):
        return f"{self.nome}"

    class Meta:
        # definindo nome da nossa tabela
        db_table = 'cliente'
        # ordenando por nome
        ordering = ['nome']
Example #23
0
class User(AbstractBaseUser):
    email = models.EmailField(
        verbose_name='email address',
        max_length=255,
        unique=True,
        null=True,
    )
    full_name = models.CharField(max_length=255, blank=True, null=True)
    active = models.BooleanField(default=True)
    staff = models.BooleanField(default=False)  # a admin user; non super-user
    admin = models.BooleanField(default=False)  # a superuser
    timestamp = models.DateTimeField(auto_now_add=True)
    cpf = CPFField('cpf', null=True, blank=True)
    date_of_birth = models.DateField(verbose_name=_("Date of birth"),
                                     blank=True,
                                     null=True)
    address1 = models.CharField(verbose_name=_("Address line 1"),
                                max_length=1024,
                                blank=True,
                                null=True)
    address2 = models.CharField(verbose_name=_("Address line 2"),
                                max_length=1024,
                                blank=True,
                                null=True)
    zip_code = models.CharField(verbose_name=_("Postal Code"),
                                max_length=12,
                                blank=True,
                                null=True)
    city = models.CharField(verbose_name=_("City"),
                            max_length=1024,
                            blank=True,
                            null=True)
    country = CountryField(blank=True, null=True)
    phone_regex = RegexValidator(
        regex=r"^\+(?:[0-9]●?){6,14}[0-9]$",
        message=
        _("Enter a valid international mobile phone number starting with +(country code)"
          ))
    mobile_phone = models.CharField(validators=[phone_regex],
                                    verbose_name=_("Mobile phone"),
                                    max_length=17,
                                    blank=True,
                                    null=True)
    additional_information = models.CharField(
        verbose_name=_("Additional information"),
        max_length=4096,
        blank=True,
        null=True)
    photo = models.ImageField(verbose_name=_("Photo"),
                              upload_to='photos',
                              default='photos/default-user-avatar.png')
    # notice the absence of a "Password field", that is built in.

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['full_name'
                       ]  # Email & Password are required by default.

    objects = UserManager()

    def get_full_name(self):
        # The user is identified by their email address
        return self.full_name

    def get_short_name(self):
        # The user is identified by their e mail address
        return self.email

    def __str__(self):  # __unicode__ on Python 2
        return self.email

    def has_perm(self, perm, obj=None):
        "Does the user have a specific permission?"
        # Simplest possible answer: Yes, always
        return True

    def has_module_perms(self, app_label):
        "Does the user have permissions to view the app `app_label`?"
        # Simplest possible answer: Yes, always
        return True

    @property
    def is_staff(self):
        "Is the user a member of staff?"
        return self.staff

    @property
    def is_admin(self):
        "Is the user a admin member?"
        return self.admin

    @property
    def is_active(self):
        "Is the user active?"
        return self.active
Example #24
0
class EnviarEmailEducacao(models.Model):
    nome = models.EmailField(max_length=150)
    email = models.EmailField(max_length=254)
    cadastro_pf = CPFField('CPF')
    rg = models.CharField(max_length=15)
    escola = models.EmailField(max_length=100)
Example #25
0
class Entry(TimeStampedModel):
    VISIBILITY_CHOICES = (('anonimous', _('I don\'t want identify myself')),
                          ('public', _('I want indentify myself')))

    GENDER_CHOICES = (('not-answer', _('Not answer')), ('female', _('Female')),
                      ('male', _('Male')))

    AGE_GROUP_CHOICES = (('up to 18 years', 'até 18 anos'), ('18 to 24 years',
                                                             '18 a 24 anos'),
                         ('25 to 34 years', '25 a 34 anos'), ('35 to 44 years',
                                                              '35 a 44 anos'),
                         ('45 to 54 years', '45 a 54 anos'), ('55 to 64 years',
                                                              '55 a 64 anos'),
                         ('more than 65 years', 'mais de 65 anos'))

    received = models.DateTimeField(_('received'),
                                    default=None,
                                    blank=True,
                                    null=True)
    source = models.ForeignKey('EntrySource',
                               verbose_name=_('Source'),
                               blank=True,
                               default=None,
                               null=True,
                               on_delete=models.CASCADE)
    entry_type = models.ForeignKey('EntryType',
                                   verbose_name=_('Type'),
                                   on_delete=models.CASCADE)
    visibility = models.CharField(_('visibility'),
                                  default='public',
                                  choices=VISIBILITY_CHOICES,
                                  max_length=255)
    name = models.CharField(_('name'), blank=True, max_length=255, null=True)
    cpf = CPFField(null=True, default=None)
    phone = PhoneNumberField(_('phone'), null=True, default=None, blank=True)
    district = models.CharField(_('district'),
                                blank=True,
                                max_length=255,
                                null=True)
    gender = models.CharField(_('gender'),
                              choices=GENDER_CHOICES,
                              max_length=255,
                              default='',
                              blank=True,
                              null=True)
    age_group = models.CharField(_('age group'),
                                 choices=AGE_GROUP_CHOICES,
                                 blank=True,
                                 max_length=255,
                                 null=True)
    subject = models.CharField(_('subject'), max_length=255)
    protocol = models.CharField(_('protocol'), blank=True, max_length=255)
    message = models.TextField(_('message'))
    email = models.EmailField(_('email'),
                              blank=True,
                              max_length=255,
                              null=True)
    topic = models.ForeignKey('EntryTopic',
                              default=None,
                              null=True,
                              verbose_name=_('topic'),
                              on_delete=models.CASCADE)
    assigned = models.PositiveIntegerField(_('assigned'),
                                           blank=True,
                                           null=True,
                                           default=None)
    status = models.ForeignKey('EntryStatus',
                               verbose_name=_('status'),
                               default=None,
                               null=True,
                               on_delete=models.CASCADE)
    answer = models.TextField(_('answer'), blank=True)
    answer_file = models.FileField(_('answer file'),
                                   upload_to='ombudsman/answer/',
                                   blank=True)
    answer_file_label = models.CharField(_('answer file label'),
                                         blank=True,
                                         max_length=255)

    class Meta:
        verbose_name = _('Entry')
        verbose_name_plural = _('Entrys')
        ordering = ['-modified']

    def __str__(self):
        return "{0}".format(self.name or self.protocol)

    def last_author(self):
        last = Interaction.objects.filter(
            entry=self).order_by('created').last()
        author = last.author if last else ""
        return author

    last_author.short_description = _("last author")

    def is_answered(self):
        return (self.interaction_set.all().values_list(
            "author_id").distinct().count() > 1)

    is_answered.short_description = _("Answered")
    is_answered.boolean = True

    def get_interaction_count(self):
        return self.interaction_set.count()

    get_interaction_count.short_description = _("Interaction")