mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-06 18:00:57 +00:00
perf: 删除一部分 system user
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
@@ -82,75 +80,3 @@ class AssetPermsWillExpireForOrgAdminMsg(UserMessage):
|
||||
perms = AssetPermission.objects.all()[:10]
|
||||
org = Organization.objects.first()
|
||||
return cls(user, perms, org)
|
||||
|
||||
|
||||
class PermedAppsWillExpireUserMsg(UserMessage):
|
||||
def __init__(self, user, apps, day_count=0):
|
||||
super().__init__(user)
|
||||
self.apps = apps
|
||||
self.day_count = day_count
|
||||
|
||||
def get_html_msg(self) -> dict:
|
||||
subject = _("Your permed applications is about to expire")
|
||||
context = {
|
||||
'name': self.user.name,
|
||||
'count': self.day_count,
|
||||
'item_type': _('permed applications'),
|
||||
'items': [str(app) for app in self.apps]
|
||||
}
|
||||
message = render_to_string('perms/_msg_permed_items_expire.html', context)
|
||||
return {
|
||||
'subject': subject,
|
||||
'message': message
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def gen_test_msg(cls):
|
||||
from users.models import User
|
||||
from applications.models import Application
|
||||
|
||||
user = User.objects.first()
|
||||
apps = Application.objects.all()[:10]
|
||||
return cls(user, apps)
|
||||
|
||||
|
||||
class AppPermsWillExpireForOrgAdminMsg(UserMessage):
|
||||
def __init__(self, user, perms, org, day_count=0):
|
||||
super().__init__(user)
|
||||
self.perms = perms
|
||||
self.org = org
|
||||
self.day_count = day_count
|
||||
|
||||
def get_items_with_url(self):
|
||||
items_with_url = []
|
||||
perm_detail_url = urljoin(settings.SITE_URL, '/ui/#/perms/app-permissions/{}')
|
||||
for perm in self.perms:
|
||||
url = perm_detail_url.format(perm.id) + f'?oid={perm.org_id}'
|
||||
items_with_url.append([perm.name, url])
|
||||
return items_with_url
|
||||
|
||||
def get_html_msg(self) -> dict:
|
||||
items = self.get_items_with_url()
|
||||
subject = _('Application permissions is about to expire')
|
||||
context = {
|
||||
'name': self.user.name,
|
||||
'count': self.day_count,
|
||||
'item_type': _('application permissions of organization {}').format(self.org),
|
||||
'items_with_url': items
|
||||
}
|
||||
message = render_to_string('perms/_msg_item_permissions_expire.html', context)
|
||||
return {
|
||||
'subject': subject,
|
||||
'message': message
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def gen_test_msg(cls):
|
||||
from users.models import User
|
||||
from perms.models import ApplicationPermission
|
||||
from orgs.models import Organization
|
||||
|
||||
user = User.objects.first()
|
||||
perms = ApplicationPermission.objects.all()[:10]
|
||||
org = Organization.objects.first()
|
||||
return cls(user, perms, org)
|
||||
|
Reference in New Issue
Block a user