mirror of https://github.com/jumpserver/jumpserver
parent
e077afe2cc
commit
69c0eb2f50
|
@ -61,8 +61,8 @@ class AllTypes(ChoicesMixin):
|
|||
|
||||
@classmethod
|
||||
def get_automation_methods(cls):
|
||||
from assets.automations import platform_automation_methods as asset_methods
|
||||
from accounts.automations import platform_automation_methods as account_methods
|
||||
from assets.automations.methods import platform_automation_methods as asset_methods
|
||||
from accounts.automations.methods import platform_automation_methods as account_methods
|
||||
return asset_methods + account_methods
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -142,3 +142,25 @@ class EndMiddleware:
|
|||
response = self.get_response(request)
|
||||
request._e_time_end = time.time()
|
||||
return response
|
||||
|
||||
|
||||
class TranslatePatchMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
from assets.automations import methods as assets
|
||||
from accounts.automations import methods as accounts
|
||||
language = request.LANGUAGE_CODE
|
||||
if language != settings.LANGUAGE_CODE:
|
||||
settings.LANGUAGE_CODE = language
|
||||
assets.platform_automation_methods = \
|
||||
assets.get_platform_automation_methods(
|
||||
assets.BASE_DIR
|
||||
)
|
||||
accounts.platform_automation_methods = \
|
||||
accounts.get_platform_automation_methods(
|
||||
accounts.BASE_DIR
|
||||
)
|
||||
response = self.get_response(request)
|
||||
return response
|
||||
|
|
|
@ -160,6 +160,7 @@ MIDDLEWARE = [
|
|||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'jumpserver.middleware.TranslatePatchMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
|
|
Loading…
Reference in New Issue