felicity-lims/felicity/apps/user/abstract.py

31 lines
1.1 KiB
Python
Raw Normal View History

from sqlalchemy import Boolean, Column, Integer, String
from felicity.apps.abstract import BaseEntity
2024-07-28 03:52:31 +08:00
2023-12-23 01:06:14 +08:00
class AbstractBaseUser(BaseEntity):
__abstract__ = True
2024-07-28 03:52:31 +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)
@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}"