fix: template

This commit is contained in:
root 2025-07-12 23:39:57 +08:00
parent 10c802a96b
commit 8047701388
4 changed files with 14 additions and 7 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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

View File

@ -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
) )
# 保存到云端存储 # 保存到云端存储