mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-19 18:34:28 +00:00
perf: 优化 ops 任务,支持 i18n
- 内置任务名称支持了 i18n,数据库存英文,返回是翻译一下 - 任务执行中,添加 language 上下文
This commit is contained in:
@@ -9,7 +9,7 @@ from celery import current_task
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _, gettext
|
||||
|
||||
from common.utils import get_logger, lazyproperty
|
||||
from common.fields.model import (
|
||||
@@ -58,6 +58,17 @@ class Task(PeriodTaskModelMixin, OrgModelMixin):
|
||||
else:
|
||||
return False
|
||||
|
||||
@lazyproperty
|
||||
def display_name(self):
|
||||
sps = ['. ', ': ']
|
||||
spb = {str(sp in self.name): sp for sp in sps}
|
||||
sp = spb.get('True')
|
||||
if not sp:
|
||||
return self.name
|
||||
|
||||
tpl, data = self.name.split(sp, 1)
|
||||
return gettext(tpl + sp) + data
|
||||
|
||||
@property
|
||||
def timedelta(self):
|
||||
if self.latest_execution:
|
||||
|
Reference in New Issue
Block a user