- 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.
30 lines
697 B
Python
30 lines
697 B
Python
from sqlalchemy.orm import Session
|
|
|
|
from . import dto, models
|
|
|
|
"""
|
|
Service layer for Seal.
|
|
"""
|
|
|
|
|
|
class SealService:
|
|
@staticmethod
|
|
def get_seal_by_id(db: Session, seal: str):
|
|
return db.query(models.Seal).filter(models.Seal.seal == seal).first()
|
|
|
|
@staticmethod
|
|
def create_seal(db: Session, seal_data: dto.SealCreateDTO):
|
|
new_seal = models.Seal(**seal_data.dict())
|
|
db.add(new_seal)
|
|
db.commit()
|
|
db.refresh(new_seal)
|
|
return new_seal
|
|
|
|
@staticmethod
|
|
def delete_seal(db: Session, seal: str):
|
|
seal = SealService.get_seal_by_id(db, seal)
|
|
if seal:
|
|
db.delete(seal)
|
|
db.commit()
|
|
return seal
|