立项配置数据入库、审计日志数据入库、编辑页UI界面美化、设备管理内容补充、审计日志显示优化
This commit is contained in:
@@ -28,6 +28,7 @@ async def upsert(
|
||||
expected_version: int | None,
|
||||
data: StudySetupConfigData | dict,
|
||||
saved_by: uuid.UUID | None,
|
||||
force_draft: bool = False,
|
||||
) -> tuple[StudySetupConfig | None, bool]:
|
||||
existing = await get_by_study(db, study_id)
|
||||
payload = _to_storage(data)
|
||||
@@ -37,7 +38,13 @@ async def upsert(
|
||||
existing.version = existing.version + 1
|
||||
existing.config = payload
|
||||
existing.saved_by = saved_by
|
||||
existing.publish_status = "PUBLISHED" if existing.published_config == payload else "DRAFT"
|
||||
if force_draft:
|
||||
existing.publish_status = "DRAFT"
|
||||
elif existing.publish_status == "DRAFT":
|
||||
# Keep draft state sticky until explicit publish API is called.
|
||||
existing.publish_status = "DRAFT"
|
||||
else:
|
||||
existing.publish_status = "PUBLISHED" if existing.published_config == payload else "DRAFT"
|
||||
existing.updated_at = datetime.utcnow()
|
||||
await db.commit()
|
||||
await db.refresh(existing)
|
||||
|
||||
Reference in New Issue
Block a user