jumpserver/apps/terminal/forms.py

47 lines
1.2 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(),
label=_("Command storage")
)
replay_storage = forms.ChoiceField(
choices=get_all_replay_storage(),
label=_("Replay storage")
)
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 = [
'name', 'remote_addr', 'ssh_port', 'http_port', 'comment',
'command_storage', 'replay_storage',
]
2016-10-19 10:33:14 +00:00
help_texts = {
2017-10-31 03:34:20 +00:00
'ssh_port': _("Coco ssh listen port"),
'http_port': _("Coco http/ws listen port"),
2016-10-19 10:33:14 +00:00
}