- 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
906 B
Python
30 lines
906 B
Python
from sqlalchemy.orm import Session
|
|
|
|
from . import dto, models
|
|
|
|
|
|
class PermissionRuleOctService:
|
|
@staticmethod
|
|
def get_permission_by_id(db: Session, permission: str):
|
|
return (
|
|
db.query(models.PermissionRuleOct)
|
|
.filter(models.PermissionRuleOct.permission == permission)
|
|
.first()
|
|
)
|
|
|
|
@staticmethod
|
|
def create_permission(db: Session, permission_data: dto.PermissionRuleOctCreateDTO):
|
|
new_permission = models.PermissionRuleOct(**permission_data.dict())
|
|
db.add(new_permission)
|
|
db.commit()
|
|
db.refresh(new_permission)
|
|
return new_permission
|
|
|
|
@staticmethod
|
|
def delete_permission(db: Session, permission: str):
|
|
permission = PermissionRuleOctService.get_permission_by_id(db, permission)
|
|
if permission:
|
|
db.delete(permission)
|
|
db.commit()
|
|
return permission
|