From c037ce1c29081349fdf3ece94bb33bc7ff877bfb Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Fri, 15 Aug 2025 18:41:46 +0800 Subject: [PATCH] perf: Send report email --- apps/i18n/lina/en.json | 4 +++- apps/i18n/lina/zh.json | 5 ++++- apps/reports/views.py | 13 ++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/i18n/lina/en.json b/apps/i18n/lina/en.json index 0abe783ab..1d792f5e5 100644 --- a/apps/i18n/lina/en.json +++ b/apps/i18n/lina/en.json @@ -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" } \ No newline at end of file diff --git a/apps/i18n/lina/zh.json b/apps/i18n/lina/zh.json index adfd459f5..c14247c19 100644 --- a/apps/i18n/lina/zh.json +++ b/apps/i18n/lina/zh.json @@ -1612,5 +1612,8 @@ "removeWarningMsg": "你确定要移除", "setVariable": "设置参数", "userId": "用户ID", - "userName": "用户名" + "userName": "用户名", + "ExportAsPDF": "导出 PDF", + "EMailReport": "发送邮件报告", + "Print": "打印" } \ No newline at end of file diff --git a/apps/reports/views.py b/apps/reports/views.py index 05dcb320b..ef816eb5d 100644 --- a/apps/reports/views.py +++ b/apps/reports/views.py @@ -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")