解决bug
This commit is contained in:
@@ -152,7 +152,35 @@ def api_create_task():
|
||||
# 确保 preview_recipients 是 JSON 字符串
|
||||
if 'preview_recipients' in data and isinstance(data['preview_recipients'], list):
|
||||
data['preview_recipients'] = json.dumps(data['preview_recipients'])
|
||||
|
||||
# 转换时间格式
|
||||
if 'created_at' in data:
|
||||
try:
|
||||
date = datetime.strptime(data['created_at'], '%a, %d %b %Y %H:%M:%S GMT')
|
||||
data['created_at'] = date.strftime('%Y-%m-%d %H:%M:%S')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if 'updated_at' in data:
|
||||
try:
|
||||
date = datetime.strptime(data['updated_at'], '%a, %d %b %Y %H:%M:%S GMT')
|
||||
data['updated_at'] = date.strftime('%Y-%m-%d %H:%M:%S')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if 'schedule_time' in data:
|
||||
try:
|
||||
date = datetime.strptime(data['schedule_time'], '%a, %d %b %Y %H:%M:%S GMT')
|
||||
data['schedule_time'] = date.strftime('%Y-%m-%d %H:%M:%S')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if 'recurring_end' in data and data['recurring_end']:
|
||||
try:
|
||||
date = datetime.strptime(data['recurring_end'], '%a, %d %b %Y %H:%M:%S GMT')
|
||||
data['recurring_end'] = date.strftime('%Y-%m-%d %H:%M:%S')
|
||||
except ValueError:
|
||||
pass
|
||||
# 创建任务
|
||||
db = current_app.dashboard_server.task_db
|
||||
task = db.create_task(data)
|
||||
@@ -166,7 +194,7 @@ def api_create_task():
|
||||
}
|
||||
})
|
||||
except Exception as e:
|
||||
logger.error(f"创建任务失败: {e}")
|
||||
logger.exception(f"创建任务失败: {e}")
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user