- Enhanced TenantMiddleware to validate tenant information from JWT tokens. - Added LicenseValidationMiddleware to check tenant licenses before processing requests. - Updated security utilities to extract tenant information from tokens and validate company access. - Introduced CompanyStore to manage active company state and handle company switching in the frontend. - Modified API routes to include company_id in requests for better resource management. - Improved logging and error handling throughout the middleware and API layers. - Updated frontend components to reflect changes in company management and selection. - Added new API route for fetching user's companies with proper authentication handling.
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
from pydantic import BaseModel, Field, ConfigDict
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
class PedimentoValidationBase(BaseModel):
|
|
"""Base schema for Pedimento Validation"""
|
|
|
|
pedimento_id: int = Field(..., description="Pedimento ID")
|
|
tenant_id: int = Field(..., description="Tenant ID")
|
|
validator: Optional[str] = Field(None, max_length=3, description="Validator")
|
|
validation_ack: Optional[str] = Field(
|
|
None, max_length=8, description="Validation acknowledgment"
|
|
)
|
|
pre_ack: Optional[str] = Field(None, max_length=8, description="Pre-acknowledgment")
|
|
line_signature: Optional[str] = Field(
|
|
None, max_length=50, description="Line signature"
|
|
)
|
|
electronic_signature: Optional[str] = Field(
|
|
None, max_length=999, description="Electronic signature"
|
|
)
|
|
certificate_number: Optional[str] = Field(
|
|
None, max_length=99, description="Certificate number"
|
|
)
|
|
validator_id: Optional[int] = Field(None, description="Validator ID")
|
|
responsible_id: Optional[int] = Field(None, description="Responsible ID")
|
|
|
|
|
|
class PedimentoValidationCreate(PedimentoValidationBase):
|
|
"""Schema for creating a new Pedimento Validation"""
|
|
|
|
pass
|
|
|
|
|
|
class PedimentoValidationUpdate(BaseModel):
|
|
"""Schema for updating a Pedimento Validation"""
|
|
|
|
validator: Optional[str] = Field(None, max_length=3)
|
|
validation_ack: Optional[str] = Field(None, max_length=8)
|
|
pre_ack: Optional[str] = Field(None, max_length=8)
|
|
line_signature: Optional[str] = Field(None, max_length=50)
|
|
electronic_signature: Optional[str] = Field(None, max_length=999)
|
|
certificate_number: Optional[str] = Field(None, max_length=99)
|
|
validator_id: Optional[int] = None
|
|
responsible_id: Optional[int] = None
|
|
|
|
|
|
class PedimentoValidationResponse(PedimentoValidationBase):
|
|
"""Schema for Pedimento Validation response"""
|
|
|
|
id: int
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|