class CustomUser(AbstractUser): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) username = None email = models.EmailField(_('email address'), unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return str(self.email) @property def fullname(self): return f'{self.first_name} {self.last_name}' @property def nickname(self): return f'{self.first_name}_{self.last_name}'.lower() @property def media_path(self): timestamp = str(self.date_joined).split(' ')[0] directory_name = f'{timestamp}_{self.nickname}' return directory_name
class CustomUser(AbstractUser): USER_TYPE_CHOICES = ( (1, 'general'), (2, 'admin') ) user_type = models.PositiveSmallIntegerField( choices=USER_TYPE_CHOICES) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) objects = CustomUserManager() is_premium = models.BooleanField( _('premium status'), default=False, help_text=_( 'Designates whether the user is premium or not' ), ) duration = models.IntegerField(default=1) def __str__(self): return self.email
class User(AbstractBaseUser, PermissionsMixin): # ROLES ADMIN = "admin" INPUT = "input" LOOK = "look" ROLE_CHOICES = ( (ADMIN, "Admin"), (INPUT, "input"), (LOOK, "look") ) class Meta: verbose_name = 'user' verbose_name_plural = 'users' # FIELDS username = models.TextField(unique=True) name = models.TextField() role = models.TextField(choices=ROLE_CHOICES, default="look") phone_number = PhoneNumberField() address = models.TextField() salary = models.PositiveBigIntegerField(null=True) created_at = models.DateTimeField(default=timezone.now) is_staff = models.BooleanField(_('staff status'), default=False) USERNAME_FIELD = "username" REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.username
class User(AbstractUser): email = models.EmailField(unique=True) # Optional fields full_name = models.CharField(max_length=100, null=True, blank=True) username = models.CharField(max_length=100, null=True, blank=True) website = models.URLField(null=True, blank=True) first_name = None last_name = None USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email # Number of resources count added by a user @property def added_resource_count(self): return self.resource_cb.count() # Number of resource categiry view count added by a user @property def added_resource_category_view_count(self): """ Count the sum of total views(hits) in each category to which a user has added a resource. Let's say a user has added 5 resources on java, python and web development categories, not java and python and webdevelopment each has 10, 20 and 30 total hits respectively, so this property will return 60(=10+20+30). """ count = 'N/A' return count
class User(AbstractBaseUser): image = models.ForeignKey("assets.Image", on_delete=models.CASCADE, null=True) email = models.EmailField("email", max_length=140, unique=True) email_verified = models.BooleanField(default=False) phone = models.CharField("Contato", max_length=14) name = models.CharField("Nome", max_length=60) nick = models.CharField("Nome", max_length=20) created = models.DateTimeField("Data de criação", auto_now_add=True) updated = models.DateTimeField("Data de modificação", auto_now=True) objects = CustomUserManager() USERNAME_FIELD = "email" REQUIRED_FIELDS = [] class Meta: verbose_name = "Usuário" verbose_name_plural = "Usuários" ordering = ['-created'] def get_full_name(self): return f'{self.name} {self.nick}' def get_short_name(self): return self.nick
class CustomUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField( verbose_name='email address', max_length=255, unique=True, ) first_name = models.CharField(verbose_name='first name', max_length=30, blank=True) last_name = models.CharField(verbose_name='last name', max_length=30, blank=True) is_admin = models.BooleanField(default=False) is_group_admin = models.BooleanField( default=False, help_text= 'Designates whether the user is the administrator of a Group Membership.', ) is_staff = models.BooleanField( verbose_name='staff status', default=False, help_text='Designates whether the user can log into this admin site.', ) is_active = models.BooleanField( verbose_name='active', default=True, help_text= 'Designates whether this user should be treated as active. Unselect this instead of deleting accounts.' ) date_joined = models.DateTimeField(verbose_name='date joined', default=timezone.now) objects = CustomUserManager() USERNAME_FIELD = 'email' def get_full_name(self): full_name = '%s %s' % (self.first_name, self.last_name) return full_name.strip() def get_short_name(self): return self.first_name def email_user(self, subject, message, from_email=None, **kwargs): send_mail(subject, message, from_email, [self.email], **kwargs) def get_customer(self): return self.customer @cached_property def full_name(self): return self.get_full_name() def __unicode__(self): return self.get_full_name() class Meta: verbose_name = 'user' verbose_name_plural = 'users'
class User(AbstractUser): email = models.EmailField(_('email address'), unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email
class User(AbstractBaseUser, PermissionsMixin): name = models.CharField(_('name'), max_length=100) email = models.EmailField(_('email address'), unique=True) username = models.CharField(_('username'), unique=True, max_length=100) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['name', 'email'] objects = CustomUserManager()
class CustomUser(AbstractUser): username = None email = models.EmailField("Email address", unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = ('first_name', 'last_name') objects = CustomUserManager() def __str__(self): return self.email
class User(AbstractUser): SELLER = 'seller' BUYER = 'buyer' USER_TYPES = ( (SELLER, 'Seller'), (BUYER, 'Buyer'), ) username = None email = models.EmailField(_('email address'), unique=True) full_name = models.CharField(max_length=100, null=True, blank=True) phone_number = PhoneNumberField(null=True, blank=True) verified_account = models.BooleanField(default=False) street_address = models.CharField(max_length=120, null=True, blank=True) city = models.CharField(max_length=120, null=True, blank=True) state = models.CharField(max_length=2, choices=STATE_CHOICES, null=True, blank=True) zip_code = models.IntegerField(default=0) business_name = models.CharField(max_length=120, null=True, blank=True) user_type = models.CharField(max_length=10, choices=USER_TYPES, default=SELLER) dwolla_customer_id = models.CharField(max_length=255, null=True, blank=True) dwolla_customer_url = models.URLField(max_length=255, null=True, blank=True) master_account_url = models.URLField(max_length=255, null=True, blank=True) ssn = models.CharField(max_length=50, null=True, blank=True) date_of_birth = models.DateField(null=True, blank=True) stripe_customer_id = models.CharField(max_length=250, null=True, blank=True) stripe_account_id = models.CharField(max_length=250, null=True, blank=True) stripe_payment_method = models.CharField(max_length=2000, null=True, blank=True) return_address = models.TextField(null=True, blank=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email def get_fund_source(self): return self.fundingsource_set.all().order_by('-id').first()
class User(AbstractUser): username = None email = models.CharField(max_length=200, unique=True, db_index=True) email_verified = models.BooleanField(default=False) verification_key = models.CharField(max_length=100, blank=True, null=True) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email
class User(AbstractUser): email = models.EmailField(verbose_name='Email addres', max_length=250, unique=True) username = models.CharField(verbose_name='Username', max_length=50, unique=True) create_time = models.DateTimeField(auto_now_add=True) update_time = models.DateTimeField(auto_now=True) active = models.BooleanField(default=True) admin = models.BooleanField(default=False) objects = CustomUserManager() USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['email'] class Meta: verbose_name = _("User") verbose_name_plural = _("users") ordering = ["-create_time", 'username'] def get_email_field_name(self): return self.email def get_username(self): return self.username # def has_perm(self, perm, obj=None): # return True # def has_module_perms(self, app_label): # return True @property def is_admin(self): return self.admin @property def is_active(self): return self.active @property def is_staff(self): return self.admin def __str__(self): return self.email
class CustomUser(AbstractUser): username = None email = models.EmailField(_('email address'), unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() nickname = models.CharField(blank=True, unique=True, max_length=20, verbose_name='닉네임') birthday = models.DateField(blank=True, null=True, verbose_name='생년월일') def __str__(self): return self.email
class User(AbstractUser): is_nursery = models.BooleanField(default=False) email = models.EmailField(unique=True) # Optional fields full_name = models.CharField(max_length=100, null=True, blank=True) username = models.CharField(max_length=100, null=True, blank=True) first_name = None last_name = None USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email
class CustomUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('email address'), unique=True) first_name = models.CharField(max_length=150) last_name = models.CharField(max_length=150, blank=True) about = models.TextField(_('about'), max_length=500, blank=True) country = CountryField() # User Status is_active = models.BooleanField(default=False) signup_confirmation = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) objects = CustomUserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class Meta: verbose_name = "accounts" verbose_name_plural = "accounts"
class CustomUser(AbstractUser): username = models.CharField(blank=True, null=True, max_length=100, validators=[UnicodeUsernameValidator()]) email = models.EmailField(_('email address'), unique=True) balance = models.FloatField(default=0) id_tg = models.IntegerField(blank=True, null=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email @classmethod def is_user_email(self, email): try: user = self.objects.get(email=email) return True except ObjectDoesNotExist: return False
class CustomUser(AbstractBaseUser, PermissionsMixin): """ A fully featured User model with admin-compliant permissions that uses a full-length email field as the username. Email and password are required. Other fields are optional. """ username = models.CharField(_('username'), max_length=254, unique=True) email = models.EmailField(_('email field'), max_length=254) first_name = models.CharField(_('first name'), max_length=30, blank=True) last_name = models.CharField(_('last name'), max_length=30, blank=True) is_staff = models.BooleanField( _('staff status'), default=False, help_text=_('Designates whether the user can log into this admin ' 'site.')) is_active = models.BooleanField( _('active'), default=True, help_text=_('Designates whether this user should be treated as ' 'active. Unselect this instead of deleting accounts.')) date_joined = models.DateTimeField(_('date joined'), default=timezone.now) last_visit = models.DateTimeField(_('last visit'), default=timezone.now) type_choices = ( ('B', 'Beheerder'), ('SB', 'Syntrus Beheerder'), ('SOG', 'Syntrus Projectmanager'), ('SD', 'Syntrus Derden'), ) type_user = models.CharField(max_length=3, choices=type_choices, default='SD') belegger = models.ForeignKey(Belegger, on_delete=models.CASCADE, null=True) organisatie = models.ForeignKey(Organisatie, on_delete=models.CASCADE, null=True) objects = CustomUserManager() USERNAME_FIELD = 'username' REQUIRED_FIELDS = [] class Meta: verbose_name = _('user') verbose_name_plural = _('users') def get_absolute_url(self): return "/users/%s/" % urlquote(self.username) def get_full_name(self): """ Returns the first_name plus the last_name, with a space in between. """ full_name = '%s %s' % (self.first_name, self.last_name) return full_name.strip() def get_short_name(self): "Returns the short name for the user." return self.first_name def email_user(self, subject, message, from_email=None): """ Sends an email to this User. """ send_mail(subject, message, from_email, [self.email])