30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import (Boolean, Column, DateTime, Float, ForeignKey, Index,
|
|
Integer, String, Text, UniqueConstraint)
|
|
from sqlalchemy.orm import relationship
|
|
|
|
# Import Base from the central database module instead of creating a new one
|
|
from app.core.database import Base
|
|
from models.database.base import TimestampMixin
|
|
|
|
class User(Base, TimestampMixin):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
username = Column(String, unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
role = Column(String, nullable=False, default="user") # user, admin, vendor_owner
|
|
is_active = Column(Boolean, default=True, nullable=False)
|
|
last_login = Column(DateTime, nullable=True)
|
|
|
|
# Relationships
|
|
marketplace_import_jobs = relationship(
|
|
"MarketplaceImportJob", back_populates="user"
|
|
)
|
|
owned_vendors = relationship("Vendor", back_populates="owner")
|
|
|
|
def __repr__(self):
|
|
return f"<User(username='{self.username}', email='{self.email}', role='{self.role}')>"
|