Files
Artem Kashaev 5fcb574aca
Test / test (push) Successful in 15s
Refactor code for improved readability and consistency
- Reformatted function signatures in `organization_service.py` and `task_service.py` for better alignment.
- Updated import statements across multiple files for consistency and organization.
- Enhanced test files by improving formatting and ensuring consistent use of async session factories.
- Added type hints and improved type safety in various service and test files.
- Adjusted `pyproject.toml` to include configuration for isort, mypy, and ruff for better code quality checks.
- Cleaned up unused imports and organized existing ones in several test files.
2025-12-01 16:18:03 +05:00

49 lines
1.3 KiB
Python

"""Organization ORM model and schemas."""
from __future__ import annotations
from datetime import datetime
from pydantic import BaseModel, ConfigDict
from sqlalchemy import DateTime, Integer, String, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import Base
class Organization(Base):
"""Represents a CRM organization/workspace."""
__tablename__ = "organizations"
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
name: Mapped[str] = mapped_column(String(255), nullable=False, unique=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
nullable=False,
)
members = relationship(
"OrganizationMember",
back_populates="organization",
cascade="all, delete-orphan",
)
contacts = relationship("Contact", back_populates="organization", cascade="all, delete-orphan")
deals = relationship("Deal", back_populates="organization", cascade="all, delete-orphan")
class OrganizationBase(BaseModel):
name: str
class OrganizationCreate(OrganizationBase):
pass
class OrganizationRead(OrganizationBase):
id: int
created_at: datetime
model_config = ConfigDict(from_attributes=True)