✨ Feat: [#10] user 모델 생성
This commit is contained in:
@@ -1,6 +1,59 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from common.models.baseModels import BaseModel
|
||||||
|
from common.models.choiceModels import GenderChoices, CertificateCodeUseType
|
||||||
|
from common.utils.codeManger import set_expire
|
||||||
|
|
||||||
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin, AbstractUser
|
from django.contrib.postgres.fields import ArrayField
|
||||||
|
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin
|
||||||
|
|
||||||
|
class UserManager(BaseUserManager):
|
||||||
|
def create_user(self, email, password, **kwargs):
|
||||||
|
user = self.model(email = email, **kwargs)
|
||||||
|
user.set_password(password)
|
||||||
|
user.save(using=self._db)
|
||||||
|
return user
|
||||||
|
|
||||||
|
def create_superuser(self, email=None, password=None, **extra_fields):
|
||||||
|
superuser = self.create_user(
|
||||||
|
email = email,
|
||||||
|
password = password,
|
||||||
|
)
|
||||||
|
|
||||||
|
superuser.is_staff = True
|
||||||
|
superuser.is_superuser = True
|
||||||
|
superuser.is_active = True
|
||||||
|
|
||||||
|
superuser.save(using=self._db)
|
||||||
|
return superuser
|
||||||
|
|
||||||
|
class User(BaseModel, AbstractBaseUser, PermissionsMixin):
|
||||||
|
email = models.EmailField(unique=True)
|
||||||
|
is_email_verified = models.BooleanField(default=False)
|
||||||
|
is_plers_terms_of_service = models.BooleanField(default=False)
|
||||||
|
is_terms_of_service_colio = models.BooleanField(default=False)
|
||||||
|
is_consent_personal_info = models.BooleanField(default=False)
|
||||||
|
is_consent_third_party_sharing = models.BooleanField(default=False)
|
||||||
|
is_consent_marketing = models.BooleanField(default=False)
|
||||||
|
phone = models.CharField(max_length=11)
|
||||||
|
is_phone_verified = models.BooleanField(default=False)
|
||||||
|
nickname = models.CharField(default=False)
|
||||||
|
gender = models.CharField(choices=GenderChoices.choices, max_length=1)
|
||||||
|
birth_date = models.CharField(max_length=10)
|
||||||
|
custom_url = models.CharField(max_length=20)
|
||||||
|
job_and_interests = ArrayField(models.CharField(max_length=20), default=list)
|
||||||
|
skills = ArrayField(models.CharField(max_length=20), default=list, blank=True)
|
||||||
|
external_links = ArrayField(models.TextField(), default=list, blank=True)
|
||||||
|
short_bio = models.CharField(max_length=100, blank=True)
|
||||||
|
profile_image = models.ImageField(upload_to='', blank=True)
|
||||||
|
|
||||||
|
is_staff = models.BooleanField(default=False)
|
||||||
|
is_active = models.BooleanField(default=True)
|
||||||
|
|
||||||
|
objects = UserManager()
|
||||||
|
|
||||||
|
USERNAME_FIELD = 'email'
|
||||||
|
REQUIRED_FIELDS = []
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.nickname
|
||||||
|
|
||||||
class User(AbstractUser):
|
|
||||||
pass
|
|
||||||
Reference in New Issue
Block a user