feat: 账号收集添加资产账号信息变化通知 (#12009)

Co-authored-by: feng <1304903146@qq.com>
This commit is contained in:
fit2bot
2023-11-07 13:00:09 +08:00
committed by GitHub
parent c0de0b0d8e
commit 54b89f6fee
7 changed files with 124 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
from common.tasks import send_mail_attachment_async
from notifications.notifications import UserMessage
from users.models import User
@@ -51,3 +53,25 @@ class ChangeSecretExecutionTaskMsg(object):
send_mail_attachment_async(
self.subject, self.message, [self.user.email], attachments
)
class GatherAccountChangeMsg(UserMessage):
subject = _('Gather account change information')
def __init__(self, user, change_info: dict):
self.change_info = change_info
super().__init__(user)
def get_html_msg(self) -> dict:
context = {'change_info': self.change_info}
message = render_to_string('accounts/asset_account_change_info.html', context)
return {
'subject': str(self.subject),
'message': message
}
@classmethod
def gen_test_msg(cls):
user = User.objects.first()
return cls(user, {})