You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/apps/terminal/forms.py

50 lines
1.4 KiB

# ~*~ coding: utf-8 ~*~
#
from django import forms
from django.utils.translation import ugettext_lazy as _
from .models import Terminal
def get_all_command_storage():
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():
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,
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,
label=_("Replay storage"),
help_text=_("Replay file can store in server disk, AWS S3, Aliyun OSS, default to server, more see docs"),
)
class Meta:
model = Terminal
fields = [
'name', 'remote_addr', 'comment',
'command_storage', 'replay_storage',
]
help_texts = {
}