- Rearranged imports in multiple files for consistency and clarity. - Updated logging middleware to exclude specific paths from logging. - Enhanced security module by cleaning up token handling and improving tenant validation. - Added tenant and company scoped mixins for better database model management. - Implemented generic CRUD routes for tenant-scoped resources. - Improved error handling and response management in API routes. - Cleaned up login and logout processes to ensure proper session management. - Introduced mechanisms to clear local storage and cookies on tenant change. - Enhanced company store to detect tenant changes and clear data accordingly. - Added new DTO mixins for currency and value affect flags.
31 lines
959 B
Python
31 lines
959 B
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, Integer
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy.sql import func
|
|
|
|
|
|
class TimestampMixin:
|
|
"""Mixin for common timestamp fields"""
|
|
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime, nullable=False, default=func.now()
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
|
)
|
|
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
|
|
|
|
class TenantScopedMixin:
|
|
"""Mixin for tenant and company scoped entities"""
|
|
|
|
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
|
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
|
|
|
|
|
class PedimentoRelatedMixin(TenantScopedMixin):
|
|
"""Mixin for entities related to pedimentos"""
|
|
|
|
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|