|
@@ -1,19 +1,29 @@
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
-from sqlalchemy import Boolean, Column, Integer, String
|
|
|
+from sqlalchemy import Boolean, Column, Integer, String, Enum
|
|
|
from sqlalchemy.orm import relationship
|
|
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
+import enum
|
|
|
+
|
|
|
+
|
|
|
if TYPE_CHECKING:
|
|
|
from .item import Item # noqa: F401
|
|
|
|
|
|
|
|
|
+class Membership(enum.Enum):
|
|
|
+ Chosen = enum.auto()
|
|
|
+ Normal = enum.auto()
|
|
|
+
|
|
|
class User(Base):
|
|
|
- id = Column(Integer, primary_key=True, index=True)
|
|
|
- full_name = Column(String, index=True)
|
|
|
- email = Column(String, unique=True, index=True, nullable=False)
|
|
|
- hashed_password = Column(String, nullable=False)
|
|
|
- is_active = Column(Boolean(), default=True)
|
|
|
- is_superuser = Column(Boolean(), default=False)
|
|
|
- items = relationship("Item", back_populates="owner")
|
|
|
+ id = Column(Integer, primary_key=True, index=True)
|
|
|
+ full_name = Column(String, index=True)
|
|
|
+ email = Column(String, unique=True, index=True, nullable=False)
|
|
|
+ hashed_password = Column(String, nullable=False)
|
|
|
+ membership = Column(Enum(Membership), nullable=False, default=Membership.Normal)
|
|
|
+ time = Column(Integer, default=0)
|
|
|
+ is_active = Column(Boolean(), default=True)
|
|
|
+ is_superuser = Column(Boolean(), default=False)
|
|
|
+ items = relationship("Item", back_populates="owner")
|
|
|
+ videos = relationship("Video", back_populates="owner")
|