- 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.
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from sqlalchemy.orm import Session
|
|
from . import models, dto
|
|
|
|
"""
|
|
Service layer for FractionRuleOctave.
|
|
"""
|
|
|
|
|
|
class FractionRuleOctaveService:
|
|
@staticmethod
|
|
def get_fraction_by_permission_line(
|
|
db: Session, permission: str, line: int, fraction: str
|
|
):
|
|
return (
|
|
db.query(models.FractionRuleOctave)
|
|
.filter(
|
|
models.FractionRuleOctave.permission == permission,
|
|
models.FractionRuleOctave.line == line,
|
|
models.FractionRuleOctave.fraction == fraction,
|
|
)
|
|
.first()
|
|
)
|
|
|
|
@staticmethod
|
|
def create_frac(db: Session, frac_data: dto.FractionRuleOctaveCreateDTO):
|
|
new_frac = models.FractionRuleOctave(**frac_data.model_dump())
|
|
db.add(new_frac)
|
|
db.commit()
|
|
db.refresh(new_frac)
|
|
return new_frac
|
|
|
|
@staticmethod
|
|
def delete_fraction(db: Session, permission: str, line: int, fraction: str):
|
|
frac = FractionRuleOctaveService.get_fraction_by_permission_line(
|
|
db, permission, line, fraction
|
|
)
|
|
if frac:
|
|
db.delete(frac)
|
|
db.commit()
|
|
return frac
|