jumpserver/apps/terminal/forms.py

42 lines
1.1 KiB
Python
Raw Normal View History

2016-10-19 10:33:14 +00:00
# ~*~ coding: utf-8 ~*~
#
from django import forms
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():
from common import utils
2018-11-19 04:18:52 +00:00
command_storage = utils.get_command_storage_setting()
for k, v in command_storage.items():
yield (k, k)
2018-01-23 02:36:20 +00:00
2018-02-26 10:05:41 +00:00
def get_all_replay_storage():
from common import utils
2018-11-19 04:18:52 +00:00
replay_storage = utils.get_replay_storage_setting()
for k, v in replay_storage.items():
yield (k, k)
2018-02-26 10:05:41 +00:00
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',
]