mirror of https://github.com/jumpserver/jumpserver
perf: Send report email
parent
ee7c6b4708
commit
c037ce1c29
|
@ -1604,5 +1604,7 @@
|
||||||
"removeWarningMsg": "Are you sure you want to remove",
|
"removeWarningMsg": "Are you sure you want to remove",
|
||||||
"setVariable": "Set variable",
|
"setVariable": "Set variable",
|
||||||
"userId": "User ID",
|
"userId": "User ID",
|
||||||
"userName": "User name"
|
"userName": "User name",
|
||||||
|
"ExportAsPDF": "Export as PDF",
|
||||||
|
"EMailReport": "Email Report"
|
||||||
}
|
}
|
|
@ -1612,5 +1612,8 @@
|
||||||
"removeWarningMsg": "你确定要移除",
|
"removeWarningMsg": "你确定要移除",
|
||||||
"setVariable": "设置参数",
|
"setVariable": "设置参数",
|
||||||
"userId": "用户ID",
|
"userId": "用户ID",
|
||||||
"userName": "用户名"
|
"userName": "用户名",
|
||||||
|
"ExportAsPDF": "导出 PDF",
|
||||||
|
"EMailReport": "发送邮件报告",
|
||||||
|
"Print": "打印"
|
||||||
}
|
}
|
|
@ -111,11 +111,14 @@ class ExportPdfView(View):
|
||||||
|
|
||||||
|
|
||||||
class SendMailView(View):
|
class SendMailView(View):
|
||||||
def get(self, request):
|
|
||||||
|
def post(self, request):
|
||||||
chart_name = request.GET.get('chart')
|
chart_name = request.GET.get('chart')
|
||||||
email = "ibuler@qq.com"
|
if not chart_name:
|
||||||
if not chart_name or not email:
|
return HttpResponseBadRequest('Missing chart parameter')
|
||||||
return HttpResponseBadRequest('Missing chart or email parameter')
|
email = request.user.email
|
||||||
|
if not email:
|
||||||
|
return HttpResponseBadRequest('Missing email parameter')
|
||||||
sessionid = request.COOKIES.get(settings.SESSION_COOKIE_NAME)
|
sessionid = request.COOKIES.get(settings.SESSION_COOKIE_NAME)
|
||||||
if not sessionid:
|
if not sessionid:
|
||||||
return HttpResponseBadRequest('No sessionid found in cookies')
|
return HttpResponseBadRequest('No sessionid found in cookies')
|
||||||
|
@ -138,7 +141,7 @@ class SendMailView(View):
|
||||||
|
|
||||||
# 4. 发送邮件
|
# 4. 发送邮件
|
||||||
subject = f"{title} 报表"
|
subject = f"{title} 报表"
|
||||||
from_email = settings.EMAIL_HOST_USER
|
from_email = settings.EMAIL_FROM
|
||||||
to = [email]
|
to = [email]
|
||||||
msg = EmailMultiAlternatives(subject, '', from_email, to)
|
msg = EmailMultiAlternatives(subject, '', from_email, to)
|
||||||
msg.attach_alternative(html_content, "text/html")
|
msg.attach_alternative(html_content, "text/html")
|
||||||
|
|
Loading…
Reference in New Issue