- 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.
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from sqlalchemy.orm import Session
|
|
|
|
from . import dto, models
|
|
|
|
"""
|
|
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
|