jumpserver/apps/terminal/forms.py

47 lines
1.3 KiB
Python
Raw Normal View History

2016-10-19 10:33:14 +00:00
# ~*~ coding: utf-8 ~*~
#
from django import forms
2018-01-23 02:36:20 +00:00
from django.conf import settings
2017-10-31 03:34:20 +00:00
from django.utils.translation import ugettext_lazy as _
2016-10-19 10:33:14 +00:00
from .models import Terminal
2018-01-23 02:36:20 +00:00
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)
2018-02-26 10:05:41 +00:00
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)
2016-10-19 10:33:14 +00:00
class TerminalForm(forms.ModelForm):
2018-02-28 02:39:38 +00:00
command_storage = forms.ChoiceField(
choices=get_all_command_storage(),
2018-03-14 05:13:32 +00:00
label=_("Command storage"),
help_text=_("Command can store in server db or ES, default to server, more see docs"),
2018-02-28 02:39:38 +00:00
)
replay_storage = forms.ChoiceField(
choices=get_all_replay_storage(),
2018-03-14 05:13:32 +00:00
label=_("Replay storage"),
help_text=_("Replay file can store in server disk, AWS S3, Aliyun OSS, default to server, more see docs"),
2018-02-28 02:39:38 +00:00
)
2018-01-23 02:36:20 +00:00
2016-10-19 10:33:14 +00:00
class Meta:
model = Terminal
2018-02-28 02:39:38 +00:00
fields = [
2018-03-14 05:13:32 +00:00
'name', 'remote_addr', 'comment',
2018-02-28 02:39:38 +00:00
'command_storage', 'replay_storage',
]
2016-10-19 10:33:14 +00:00
help_texts = {
}