2024-08-04 16:17:51 +08:00
|
|
|
from sqlalchemy import Boolean, Column, Integer, String
|
2023-05-12 02:32:50 +08:00
|
|
|
|
2024-08-04 16:17:51 +08:00
|
|
|
from felicity.apps.abstract import BaseEntity
|
2024-07-28 03:52:31 +08:00
|
|
|
|
2023-12-23 01:06:14 +08:00
|
|
|
|
2024-08-04 16:17:51 +08:00
|
|
|
class AbstractBaseUser(BaseEntity):
|
2023-05-12 02:32:50 +08:00
|
|
|
__abstract__ = True
|
2024-07-28 03:52:31 +08:00
|
|
|
|
2023-05-12 02:32:50 +08:00
|
|
|
first_name = Column(String, index=True)
|
|
|
|
last_name = Column(String, index=True)
|
|
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
|
|
mobile_phone = Column(String, nullable=True)
|
|
|
|
business_phone = Column(String, nullable=True)
|
|
|
|
user_name = Column(String, unique=True, index=True, nullable=False)
|
|
|
|
hashed_password = Column(String, nullable=False)
|
|
|
|
login_retry = Column(Integer)
|
|
|
|
is_blocked = Column(Boolean(), default=False)
|
2024-07-24 04:30:01 +08:00
|
|
|
avatar = Column(String, nullable=True)
|
|
|
|
bio = Column(String, nullable=True)
|
2024-07-28 03:52:31 +08:00
|
|
|
default_route = Column(Boolean(), nullable=True)
|
2024-07-24 04:30:01 +08:00
|
|
|
is_active = Column(Boolean(), default=True)
|
|
|
|
is_superuser = Column(Boolean(), default=False)
|
2023-05-12 02:32:50 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def has_password(self):
|
|
|
|
return True if self.hashed_password else False
|
|
|
|
|
2024-07-24 04:30:01 +08:00
|
|
|
@property
|
|
|
|
def full_name(self):
|
|
|
|
return f"{self.first_name} {self.last_name}"
|