[Update] 修改系统设置-命令/录像存储页面(添加,删除)

This commit is contained in:
BaiJiangJie
2018-10-23 19:22:18 +08:00
parent c9f4b104c7
commit 284e8be45c
13 changed files with 710 additions and 71 deletions

View File

@@ -2,6 +2,9 @@ from importlib import import_module
from django.conf import settings
from .command.serializers import SessionCommandSerializer
from common import utils
from common.models import common_settings, Setting
TYPE_ENGINE_MAPPING = {
'elasticsearch': 'terminal.backends.command.es',
}
@@ -16,7 +19,9 @@ def get_command_storage():
def get_terminal_command_storages():
storage_list = {}
for name, params in settings.TERMINAL_COMMAND_STORAGE.items():
command_storage = utils.get_command_storage_or_create_default_storage()
for name, params in command_storage.items():
tp = params['TYPE']
if tp == 'server':
storage = get_command_storage()

View File

@@ -2,36 +2,39 @@
#
from django import forms
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from .models import Terminal
def get_all_command_storage():
# storage_choices = []
from common.models import Setting
Setting.refresh_all_settings()
for k, v in settings.TERMINAL_COMMAND_STORAGE.items():
yield (k, k)
from common import utils
command_storage = utils.get_command_storage_or_create_default_storage()
command_storage_choice = []
for k, v in command_storage.items():
command_storage_choice.append((k, k))
return command_storage_choice
def get_all_replay_storage():
# storage_choices = []
from common.models import Setting
Setting.refresh_all_settings()
for k, v in settings.TERMINAL_REPLAY_STORAGE.items():
yield (k, k)
from common import utils
replay_storage = utils.get_replay_storage_or_create_default_storage()
replay_storage_choice = []
for k, v in replay_storage.items():
replay_storage_choice.append((k, k))
return replay_storage_choice
class TerminalForm(forms.ModelForm):
command_storage = forms.ChoiceField(
choices=get_all_command_storage(),
choices=get_all_command_storage,
label=_("Command storage"),
help_text=_("Command can store in server db or ES, default to server, more see docs"),
)
replay_storage = forms.ChoiceField(
choices=get_all_replay_storage(),
choices=get_all_replay_storage,
label=_("Replay storage"),
help_text=_("Replay file can store in server disk, AWS S3, Aliyun OSS, default to server, more see docs"),
)