fix: template
This commit is contained in:
parent
10c802a96b
commit
8047701388
|
|
@ -159,8 +159,12 @@ PostgreSQL 驱动 psycopg2 未安装。请安装:
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
# 处理 draft_content,如果 template_info 有 draft_content 属性则使用,否则为空对象
|
# 处理 draft_content
|
||||||
draft_content = getattr(template_info, 'draft_content', {})
|
draft_content = template_info.draft_content
|
||||||
|
if draft_content is None:
|
||||||
|
draft_content = {}
|
||||||
|
|
||||||
|
logger.debug(f"Storing draft_content for template {template_id}: {type(draft_content)} with {len(draft_content)} keys")
|
||||||
|
|
||||||
cursor.execute(insert_sql, (
|
cursor.execute(insert_sql, (
|
||||||
template_id,
|
template_id,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass, field
|
||||||
from typing import Dict, List, Any, Optional
|
from typing import Dict, List, Any, Optional
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -55,4 +55,4 @@ class TemplateInfo:
|
||||||
# 创建用户
|
# 创建用户
|
||||||
user_id: str = ""
|
user_id: str = ""
|
||||||
# draft content 存储在数据库中的内容
|
# draft content 存储在数据库中的内容
|
||||||
draft_content: Dict[str, Any] = None
|
draft_content: Dict[str, Any] = field(default_factory=dict)
|
||||||
|
|
@ -252,7 +252,8 @@ class TemplateManager:
|
||||||
duration=draft_content.get('duration', 0),
|
duration=draft_content.get('duration', 0),
|
||||||
material_count=len(materials),
|
material_count=len(materials),
|
||||||
track_count=len(draft_content.get('tracks', [])),
|
track_count=len(draft_content.get('tracks', [])),
|
||||||
tags=[]
|
tags=[],
|
||||||
|
draft_content=draft_content # 设置 draft_content
|
||||||
)
|
)
|
||||||
|
|
||||||
# Save to metadata
|
# Save to metadata
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,8 @@ class TemplateManagerCloud:
|
||||||
track_count=len(draft_content.get('tracks', [])),
|
track_count=len(draft_content.get('tracks', [])),
|
||||||
tags=[],
|
tags=[],
|
||||||
is_cloud=False, # 用户导入的模板默认为本地
|
is_cloud=False, # 用户导入的模板默认为本地
|
||||||
user_id=self.user_id
|
user_id=self.user_id,
|
||||||
|
draft_content=updated_draft # 设置 draft_content
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(f"Successfully processed template: {template_name} -> {template_id}")
|
logger.info(f"Successfully processed template: {template_name} -> {template_id}")
|
||||||
|
|
@ -531,7 +532,8 @@ class TemplateManagerCloud:
|
||||||
track_count=len(draft_content.get('tracks', [])),
|
track_count=len(draft_content.get('tracks', [])),
|
||||||
tags=tags or [],
|
tags=tags or [],
|
||||||
is_cloud=is_cloud,
|
is_cloud=is_cloud,
|
||||||
user_id=self.user_id
|
user_id=self.user_id,
|
||||||
|
draft_content=draft_content # 设置 draft_content
|
||||||
)
|
)
|
||||||
|
|
||||||
# 保存到云端存储
|
# 保存到云端存储
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue