feat: 优化PDF报告生成逻辑并添加调试脚本

移除对weasyprint_available的冗余检查,使用更高效的Count查询统计家庭事项
添加debug_pdf_email.py调试脚本用于直接测试PDF生成和邮件发送功能
This commit is contained in:
2026-01-19 23:24:04 +08:00
parent e3c9d6f17d
commit c22c001ee0
4 changed files with 286 additions and 4 deletions

View File

@@ -435,6 +435,12 @@ def generate_report(request):
# 获取家庭事项统计
family_task_stats = FamilyTask.objects.values('type').annotate(count=Count('id'))
# 获取过去30天的日期列表用于生成历史PDF链接
historical_dates = []
for i in range(1, 31):
historical_date = today - timedelta(days=i)
historical_dates.append(historical_date)
context = {
'today': today,
'yesterday': yesterday,
@@ -442,6 +448,7 @@ def generate_report(request):
'yesterday_insight': yesterday_insight,
'today_plan': today_plan,
'family_task_stats': family_task_stats,
'historical_dates': historical_dates,
}
return render(request, 'core/report.html', context)