Files
alex 6c86f0f571 TT-003: complete request-module integration into modular platform
- integrated request-module into module registry
- moved backend into modules/request-module
- added manifest.json and module.py
- implemented dynamic router mounting
- implemented dynamic static mounting
- removed direct dependencies from platform core
- verified startup with request-module
- verified startup without request-module
- added implementation_report_003.md
2026-08-06 16:31:27 +03:00

40 lines
2.0 KiB
Python

"""Ticket model."""
from sqlalchemy import Column, String, Text, DateTime, ForeignKey, Integer
from sqlalchemy.orm import relationship
from request_app.models.base import Base, TimestampMixin
class Ticket(Base, TimestampMixin):
"""Ticket model."""
__tablename__ = "tickets"
__table_args__ = {"sqlite_autoincrement": True}
id = Column(Integer, primary_key=True, index=True)
subject = Column(String(4000), nullable=False)
description = Column(Text)
category_id = Column(Integer, ForeignKey("categories.id", ondelete="SET NULL"), nullable=False)
priority_id = Column(Integer, ForeignKey("priorities.id", ondelete="SET NULL"), nullable=False)
status_id = Column(Integer, ForeignKey("statuses.id", ondelete="SET NULL"), nullable=False)
source = Column(String(20), nullable=False) # email, web, phone, sms
opened_by = Column(Integer, ForeignKey("users.id", ondelete="SET NULL"), nullable=False)
assigned_to_id = Column(Integer, ForeignKey("users.id", ondelete="SET NULL"))
company_id = Column(Integer, ForeignKey("companies.id", ondelete="SET NULL"))
location_id = Column(Integer, ForeignKey("locations.id", ondelete="SET NULL"))
closed_at = Column(DateTime)
# Relationships
user = relationship("User", back_populates="tickets", foreign_keys=[opened_by])
assigned_user = relationship("User", back_populates="assigned_tickets", foreign_keys=[assigned_to_id])
category = relationship("Category", back_populates="tickets")
priority = relationship("Priority")
status = relationship("Status")
company = relationship("Company", back_populates="tickets")
location = relationship("Location", back_populates="tickets")
comments = relationship("Comment", back_populates="ticket", cascade="all, delete-orphan")
email_messages = relationship("EmailMessage", back_populates="ticket", cascade="all, delete-orphan")
def __repr__(self) -> str:
return f"<Ticket(id={self.id}, subject='{self.subject}')>"