mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Request model"""
|
|
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Enum
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from ..database import Base
|
|
import enum
|
|
|
|
class RequestStatus(str, enum.Enum):
|
|
NEW = "new"
|
|
IN_PROGRESS = "in_progress"
|
|
RESOLVED = "resolved"
|
|
CLOSED = "closed"
|
|
|
|
class RequestPriority(str, enum.Enum):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
CRITICAL = "critical"
|
|
|
|
class Request(Base):
|
|
__tablename__ = "requests"
|
|
__table_args__ = {'extend_existing': True}
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
employee_id = Column(Integer, ForeignKey("employees.id"))
|
|
department = Column(String, nullable=False)
|
|
request_type = Column(String, nullable=False)
|
|
priority = Column(Enum(RequestPriority), nullable=False)
|
|
description = Column(String, nullable=False)
|
|
status = Column(Enum(RequestStatus), nullable=False, default=RequestStatus.NEW)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
employee = relationship(
|
|
"app.models.employee.Employee",
|
|
back_populates="requests",
|
|
lazy="joined"
|
|
)
|