perf: Send report email

pull/15820/head^2
wangruidong 2025-08-15 18:41:46 +08:00 committed by Bryan
parent ee7c6b4708
commit c037ce1c29
3 changed files with 15 additions and 7 deletions

View File

@ -1604,5 +1604,7 @@
"removeWarningMsg": "Are you sure you want to remove",
"setVariable": "Set variable",
"userId": "User ID",
"userName": "User name"
"userName": "User name",
"ExportAsPDF": "Export as PDF",
"EMailReport": "Email Report"
}

View File

@ -1612,5 +1612,8 @@
"removeWarningMsg": "你确定要移除",
"setVariable": "设置参数",
"userId": "用户ID",
"userName": "用户名"
"userName": "用户名",
"ExportAsPDF": "导出 PDF",
"EMailReport": "发送邮件报告",
"Print": "打印"
}

View File

@ -111,11 +111,14 @@ class ExportPdfView(View):
class SendMailView(View):
def get(self, request):
def post(self, request):
chart_name = request.GET.get('chart')
email = "ibuler@qq.com"
if not chart_name or not email:
return HttpResponseBadRequest('Missing chart or email parameter')
if not chart_name:
return HttpResponseBadRequest('Missing chart parameter')
email = request.user.email
if not email:
return HttpResponseBadRequest('Missing email parameter')
sessionid = request.COOKIES.get(settings.SESSION_COOKIE_NAME)
if not sessionid:
return HttpResponseBadRequest('No sessionid found in cookies')
@ -138,7 +141,7 @@ class SendMailView(View):
# 4. 发送邮件
subject = f"{title} 报表"
from_email = settings.EMAIL_HOST_USER
from_email = settings.EMAIL_FROM
to = [email]
msg = EmailMultiAlternatives(subject, '', from_email, to)
msg.attach_alternative(html_content, "text/html")