mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-25 01:40:16 +00:00
* 添加站内信 * s * s * 添加接口 * fix * fix * 重构了一些 * 完成 * 完善 * s * s * s * s * s * s * 测试ok * 替换业务中发送消息的方式 * 修改 * s * 去掉 update 兼容 create * 添加 unread total 接口 * 调整json字段 Co-authored-by: xinwen <coderWen@126.com>
27 lines
816 B
Python
27 lines
816 B
Python
from django.utils.translation import gettext_lazy as _
|
|
|
|
from notifications.notifications import SystemMessage
|
|
from notifications.models import SystemMsgSubscription
|
|
from users.models import User
|
|
|
|
__all__ = ('ServerPerformanceMessage',)
|
|
|
|
|
|
class ServerPerformanceMessage(SystemMessage):
|
|
category = 'Operations'
|
|
category_label = _('Operations')
|
|
message_type_label = _('Server performance')
|
|
|
|
def __init__(self, path, usage):
|
|
self.path = path
|
|
self.usage = usage
|
|
|
|
def get_common_msg(self):
|
|
msg = _("Disk used more than 80%: {} => {}").format(self.path, self.usage.percent)
|
|
return msg
|
|
|
|
@classmethod
|
|
def post_insert_to_db(cls, subscription: SystemMsgSubscription):
|
|
admins = User.objects.filter(role=User.ROLE.ADMIN)
|
|
subscription.users.add(*admins)
|