6c86f0f571
- 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
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
"""Additional models."""
|
|
|
|
from sqlalchemy import Column, String, Text, Integer, ForeignKey, Boolean
|
|
from sqlalchemy.orm import relationship
|
|
from request_app.models.base import Base, TimestampMixin
|
|
|
|
|
|
class Company(Base, TimestampMixin):
|
|
"""Company model."""
|
|
|
|
__tablename__ = "companies"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(255), unique=True, nullable=False)
|
|
address = Column(Text)
|
|
phone = Column(String(50))
|
|
website = Column(String(255))
|
|
|
|
# Relationships
|
|
tickets = relationship("Ticket", back_populates="company")
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<Company(id={self.id}, name='{self.name}')>"
|
|
|
|
|
|
class Location(Base, TimestampMixin):
|
|
"""Location model."""
|
|
|
|
__tablename__ = "locations"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(255), unique=True, nullable=False)
|
|
address = Column(Text)
|
|
phone = Column(String(50))
|
|
|
|
# Relationships
|
|
tickets = relationship("Ticket", back_populates="location")
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<Location(id={self.id}, name='{self.name}')>"
|
|
|
|
|
|
class Department(Base, TimestampMixin):
|
|
"""Department model."""
|
|
|
|
__tablename__ = "departments"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(255), unique=True, nullable=False)
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<Department(id={self.id}, name='{self.name}')>"
|
|
|
|
|
|
class UserDepartment(Base, TimestampMixin):
|
|
"""UserDepartment model - local department assignments."""
|
|
|
|
__tablename__ = "user_departments"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
|
department_id = Column(Integer, ForeignKey("departments.id", ondelete="CASCADE"), nullable=False)
|
|
is_primary = Column(Boolean, default=False)
|
|
|
|
# Relationships
|
|
user = relationship("User")
|
|
department = relationship("Department")
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<UserDepartment(user_id={self.user_id}, department_id={self.department_id})>"
|