管理后台前后端逻辑、UI美化
This commit is contained in:
@@ -115,3 +115,27 @@ def require_study_roles(roles: Iterable[str]):
|
||||
return current_user
|
||||
|
||||
return dependency
|
||||
|
||||
|
||||
def require_study_not_locked():
|
||||
"""检查项目是否被锁定,如果锁定则拒绝所有修改请求"""
|
||||
from app.crud import study as study_crud
|
||||
|
||||
async def dependency(
|
||||
study_id: uuid.UUID,
|
||||
db: AsyncSession = Depends(get_db_session),
|
||||
):
|
||||
study = await study_crud.get(db, study_id)
|
||||
if not study:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="项目不存在",
|
||||
)
|
||||
if study.is_locked:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="项目已锁定,无法进行任何修改操作",
|
||||
)
|
||||
return study
|
||||
|
||||
return dependency
|
||||
|
||||
Reference in New Issue
Block a user