from sqlalchemy import Column, Integer, String, Boolean, DateTime, Float from sqlalchemy.orm import relationship from datetime import datetime from config.database import Base class User(Base): __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) full_name = Column(String, nullable=False) hashed_password = Column(String, nullable=False) is_active = Column(Boolean, default=True) is_admin = Column(Boolean, default=False) avatar_url = Column(String, nullable=True) bio = Column(String, nullable=True) attendance_rate = Column(Float, default=0.0) created_at = Column(DateTime, default=datetime.utcnow) updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) # Relationships event_participations = relationship("EventParticipation", back_populates="user", cascade="all, delete-orphan") created_events = relationship("Event", back_populates="creator", cascade="all, delete-orphan") albums = relationship("Album", back_populates="creator", cascade="all, delete-orphan") posts = relationship("Post", back_populates="author", cascade="all, delete-orphan") mentions = relationship("PostMention", back_populates="mentioned_user", cascade="all, delete-orphan") vlogs = relationship("Vlog", back_populates="author", cascade="all, delete-orphan") notifications = relationship("Notification", back_populates="user", cascade="all, delete-orphan") vlog_likes = relationship("VlogLike", back_populates="user", cascade="all, delete-orphan") vlog_comments = relationship("VlogComment", back_populates="user", cascade="all, delete-orphan") media_likes = relationship("MediaLike", back_populates="user", cascade="all, delete-orphan") post_likes = relationship("PostLike", back_populates="user", cascade="all, delete-orphan") post_comments = relationship("PostComment", back_populates="author", cascade="all, delete-orphan") tickets = relationship("Ticket", foreign_keys="[Ticket.user_id]", back_populates="user")