from django.contrib.auth.models import AbstractUser
from django.db.models import CharField
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.db import models
from PIL import Image


class User(AbstractUser):

    # First Name and Last Name do not cover name patterns
    # around the globe.
    name = CharField(_('Nome de usuário:'), blank=True, max_length=255)

    # Profile Models
    image = models.ImageField(verbose_name='Foto de Perfil:',
                              default='default.jpg', upload_to='profile_pics')
    birth_date = models.DateField(_('Data de Nascimento:'), null=True, blank=True)
    cpf = models.CharField(_('CPF:'), max_length=50, blank=True)
    cnpj = models.CharField(_('CNPJ:'), max_length=50, blank=True)
    bio = models.TextField(_('Descrição:'), blank=True, default='')
    cep = models.CharField(_('CEP:'), max_length=50, blank=True)
    street = models.CharField(_('Rua:'), max_length=100, blank=True)
    number_home = models.CharField(_('Número:'), max_length=10, blank=True)
    neighborhood = models.CharField(_('Bairro:'), max_length=100, blank=True)
    city = models.CharField(_('Cidade:'), max_length=50, blank=True)
    state = models.CharField(_('Estado:'), max_length=50, blank=True)
    phone = models.CharField(_('Telefone:'), max_length=50, blank=True)
    cel_phone = models.CharField(_('Celular:'), max_length=50, blank=True)

    def get_absolute_url(self):
        return reverse("users:detail", kwargs={"username": self.username})

    """def save(self):
        super().save()

        img = Image.open(self.image.path)

        if img.height > 300 or img.width > 300:
            output_size = (300, 300)
            img.thumbnail(output_size)
            img.save(self.image.path)"""

[((16, 12, 17, 78), 'django.db.models.ImageField', 'models.ImageField', (), '', False, 'from django.db import models\n'), ((13, 21, 13, 43), 'django.utils.translation.ugettext_lazy', '_', ({(13, 23, 13, 42): '"""Nome de usuário:"""'}, {}), "('Nome de usuário:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((18, 34, 18, 58), 'django.utils.translation.ugettext_lazy', '_', ({(18, 36, 18, 57): '"""Data de Nascimento:"""'}, {}), "('Data de Nascimento:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((19, 27, 19, 36), 'django.utils.translation.ugettext_lazy', '_', ({(19, 29, 19, 35): '"""CPF:"""'}, {}), "('CPF:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((20, 28, 20, 38), 'django.utils.translation.ugettext_lazy', '_', ({(20, 30, 20, 37): '"""CNPJ:"""'}, {}), "('CNPJ:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((21, 27, 21, 44), 'django.utils.translation.ugettext_lazy', '_', ({(21, 29, 21, 43): '"""Descrição:"""'}, {}), "('Descrição:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((22, 27, 22, 36), 'django.utils.translation.ugettext_lazy', '_', ({(22, 29, 22, 35): '"""CEP:"""'}, {}), "('CEP:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((23, 30, 23, 39), 'django.utils.translation.ugettext_lazy', '_', ({(23, 32, 23, 38): '"""Rua:"""'}, {}), "('Rua:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((24, 35, 24, 48), 'django.utils.translation.ugettext_lazy', '_', ({(24, 37, 24, 47): '"""Número:"""'}, {}), "('Número:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((25, 36, 25, 48), 'django.utils.translation.ugettext_lazy', '_', ({(25, 38, 25, 47): '"""Bairro:"""'}, {}), "('Bairro:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((26, 28, 26, 40), 'django.utils.translation.ugettext_lazy', '_', ({(26, 30, 26, 39): '"""Cidade:"""'}, {}), "('Cidade:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((27, 29, 27, 41), 'django.utils.translation.ugettext_lazy', '_', ({(27, 31, 27, 40): '"""Estado:"""'}, {}), "('Estado:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((28, 29, 28, 43), 'django.utils.translation.ugettext_lazy', '_', ({(28, 31, 28, 42): '"""Telefone:"""'}, {}), "('Telefone:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((29, 33, 29, 46), 'django.utils.translation.ugettext_lazy', '_', ({(29, 35, 29, 45): '"""Celular:"""'}, {}), "('Celular:')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((32, 15, 32, 74), 'django.urls.reverse', 'reverse', (), '', False, 'from django.urls import reverse\n')]