mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-05 17:30:30 +00:00
feat: 同步ldap用户消息通知
This commit is contained in:
35
apps/settings/notifications.py
Normal file
35
apps/settings/notifications.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from common.utils import get_logger
|
||||
from common.utils.timezone import local_now_display
|
||||
from notifications.notifications import UserMessage
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
|
||||
class LDAPImportMessage(UserMessage):
|
||||
def __init__(self, user, extra_kwargs):
|
||||
super().__init__(user)
|
||||
self.orgs = extra_kwargs.pop('orgs', [])
|
||||
self.end_time = extra_kwargs.pop('end_time', '')
|
||||
self.start_time = extra_kwargs.pop('start_time', '')
|
||||
self.time_start_display = extra_kwargs.pop('time_start_display', '')
|
||||
self.new_users = extra_kwargs.pop('new_users', [])
|
||||
self.errors = extra_kwargs.pop('errors', [])
|
||||
|
||||
def get_html_msg(self) -> dict:
|
||||
subject = _('Notification of Synchronized LDAP User Task Results')
|
||||
context = {
|
||||
'orgs': self.orgs,
|
||||
'start_time': self.time_start_display,
|
||||
'end_time': local_now_display(),
|
||||
'cost_time': self.end_time - self.start_time,
|
||||
'users': self.new_users,
|
||||
'errors': self.errors
|
||||
}
|
||||
message = render_to_string('ldap/_msg_import_ldap_user.html', context)
|
||||
return {
|
||||
'subject': subject,
|
||||
'message': message
|
||||
}
|
Reference in New Issue
Block a user