Download app/models/user.py from Noor2623/Smart-Query-Routing-Email-Automation-System: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/spaces/Noor2623/Smart-Query-Routing-Email-Automation-System/resolve/main/app/models/user.py
- Command line
-
hf download hf://spaces/Noor2623/Smart-Query-Routing-Email-Automation-System/app/models/user.py
-
curl -L -o user.py https://huggingface.co/spaces/Noor2623/Smart-Query-Routing-Email-Automation-System/resolve/main/app/models/user.py
1.36 kB
| from datetime import UTC, datetime | |
| from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String | |
| from sqlalchemy.orm import Mapped, mapped_column, relationship | |
| from app.core.database import Base | |
| class User(Base): | |
| __tablename__ = "users" | |
| id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True) | |
| email: Mapped[str] = mapped_column(String(255), unique=True, index=True, nullable=False) | |
| full_name: Mapped[str | None] = mapped_column(String(255), nullable=True) | |
| hashed_password: Mapped[str] = mapped_column(String(255), nullable=False) | |
| role: Mapped[str] = mapped_column(String(255), nullable=False) | |
| is_admin: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) | |
| department_id: Mapped[int | None] = mapped_column( | |
| ForeignKey("departments.id", ondelete="SET NULL"), | |
| nullable=True, | |
| ) | |
| is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) | |
| created_at: Mapped[datetime] = mapped_column( | |
| DateTime, default=lambda: datetime.now(UTC), nullable=False | |
| ) | |
| department = relationship("Department", back_populates="users") | |
| queries = relationship("Query", back_populates="student") | |
| def department_name(self) -> str | None: | |
| if self.department is None: | |
| return None | |
| return self.department.name | |