mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Создание чата5
This commit is contained in:
@@ -1,32 +1,20 @@
|
||||
"""Request model"""
|
||||
from enum import Enum
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Text
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.orm import relationship
|
||||
from app.db.base_class import Base
|
||||
|
||||
class RequestStatus(str, Enum):
|
||||
NEW = "new"
|
||||
IN_PROGRESS = "in_progress"
|
||||
COMPLETED = "completed"
|
||||
REJECTED = "rejected"
|
||||
|
||||
class RequestPriority(str, Enum):
|
||||
LOW = "low"
|
||||
MEDIUM = "medium"
|
||||
HIGH = "high"
|
||||
|
||||
class Request(Base):
|
||||
__tablename__ = "requests"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
department = Column(String, index=True)
|
||||
request_type = Column(String, index=True)
|
||||
description = Column(String)
|
||||
priority = Column(String)
|
||||
status = Column(String, default=RequestStatus.NEW)
|
||||
employee_id = Column(Integer, ForeignKey("employees.id"))
|
||||
employee_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
request_type = Column(String, nullable=False)
|
||||
description = Column(Text, nullable=False)
|
||||
priority = Column(String, nullable=False)
|
||||
status = Column(String, default="new")
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
# Определяем отношение к Employee
|
||||
employee = relationship("Employee", back_populates="requests")
|
||||
# Отношения
|
||||
employee = relationship("User", back_populates="requests")
|
||||
|
@@ -16,4 +16,7 @@ class User(Base):
|
||||
# Отношения для чата
|
||||
employee_chats = relationship("Chat", foreign_keys="[Chat.employee_id]", back_populates="employee")
|
||||
admin_chats = relationship("Chat", foreign_keys="[Chat.admin_id]", back_populates="admin")
|
||||
sent_messages = relationship("Message", back_populates="sender")
|
||||
sent_messages = relationship("Message", back_populates="sender")
|
||||
|
||||
# Отношения для заявок
|
||||
requests = relationship("Request", back_populates="employee")
|
Reference in New Issue
Block a user