Ejemplo n.º 1
0
class User(AbstractUser):
    picture = models.ImageField(upload_to='profile_pictures',
                                null=True,
                                blank=True)
    full_name = models.CharField(
        max_length=100,
        help_text=
        'Help people discover your account by using the name you\'re known by: either your full name, nickname, or business name.'
    )
    email = models.EmailField(unique=True)

    # Optional fields
    bio = models.TextField(
        null=True,
        blank=True,
        help_text=
        'Provide your personal information, even if the account is used for a business, a pet or something else. This won\'t be a part of your public profile.'
    )
    website = models.URLField(null=True, blank=True)
    phone_number = models.CharField(max_length=20, null=True, blank=True)
    gender = models.CharField(max_length=10,
                              choices=GENDER_CHOICES,
                              null=True,
                              blank=True)
    is_private_account = models.BooleanField(null=True, blank=True)

    first_name = None
    last_name = None

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = [
        'full_name',
        'username',
    ]

    objects = CustomUserManager()

    def __str__(self):
        return self.email

    @property
    def follower_count(self):
        count = self.follow_followed.count()
        return count

    @property
    def following_count(self):
        count = self.follow_follower.count()
        return count

    @property
    def posts_count(self):
        count = self.post_set.count()
        return count
Ejemplo n.º 2
0
class CustomUser(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(null=False, blank=False, unique=True)
    is_staff = models.BooleanField(default=False)
    is_user = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    date_joined = models.DateTimeField(default=timezone.now)
    valid_until = models.DateTimeField(blank=False, null=True)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['password']

    objects = CustomUserManager()

    def __str__(self):
        return self.email
Ejemplo n.º 3
0
class CustomUser(AbstractUser):
    email = models.EmailField(unique=True,
                              max_length=254,
                              verbose_name='email address')

    user_token = models.CharField(
        max_length=64,
        primary_key=True,
    )

    device_token = models.CharField(
        blank=True,
        max_length=64,
    )

    objects = CustomUserManager()
Ejemplo n.º 4
0
class User(AbstractUser):
    picture = models.ImageField(upload_to='profile_pictures',
                                null=False,
                                blank=False)
    full_name = models.CharField(max_length=100)
    email = models.EmailField(unique=True)

    first_name = None
    last_name = None

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = [
        'full_name',
    ]

    objects = CustomUserManager()

    def __str__(self):
        return self.email
class User(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(_('Email'), unique=True, blank=False)
    first_name = models.CharField(_('Nome'), max_length=150, blank=False)
    last_name = models.CharField(_('Sobrenome'), max_length=150, blank=False)
    created_at = models.DateTimeField(_('Criado em'), auto_now_add=True)
    is_superadmin = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    is_staff = models.BooleanField(default=True)

    USERNAME_FIELD = 'email'
    objects = CustomUserManager()

    class Meta:
        verbose_name = _('user')
        verbose_name_plural = _('users')

    def verify_password(self, raw_password):
        return check_password(raw_password, self.password)

    def __str__(self):
        return self.email
Ejemplo n.º 6
0
class User(AbstractUser):
    username = None
    first_name = None
    last_name = None
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    avatar = models.TextField(
        default=
        "https://fyp-images-narvitaa.s3.ap-south-1.amazonaws.com/default_avatar.png"
    )
    name = models.CharField(max_length=100)
    email = models.EmailField(_('email address'), unique=True)
    is_active = models.IntegerField(
        default=0, help_text="0: inactive, 1: active, 2: disabled")
    last_login = models.DateTimeField(auto_now=True)
    registered_on = models.DateTimeField(auto_now_add=True)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = []

    objects = CustomUserManager()

    def __str__(self):
        return self.email
Ejemplo n.º 7
0
class User(AbstractUser):
    # creating field for profile in existing model User
    picture = models.ImageField(upload_to='profile_pictures',
                                null=True,
                                blank=True)
    full_name = models.CharField(
        max_length=150
    )  # by default null and blank are false for username and email
    email = models.EmailField(unique=True)

    # Removing first and the last name from the user model.
    first_name = None
    last_name = None

    # which field will be use for username we can use either email or username.
    # if we not provide the USERNAME_FIELD it will take "username" by default
    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['full_name', 'username']

    # Accessing Custom User Manager,we define this CustomUserManager in managers.py file into user app.
    objects = CustomUserManager()

    def __str__(self):
        return self.email