jumpserver/apps/terminal/forms.py

33 lines
942 B
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)
2016-10-19 10:33:14 +00:00
class TerminalForm(forms.ModelForm):
2018-01-23 02:36:20 +00:00
command_storage = forms.ChoiceField(choices=get_all_command_storage(),
label=_("Command storage"))
2016-10-19 10:33:14 +00:00
class Meta:
model = Terminal
2018-01-20 14:22:09 +00:00
fields = ['name', 'remote_addr', 'ssh_port', 'http_port', 'comment', 'command_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
}
2016-12-26 16:59:52 +00:00
widgets = {
'name': forms.TextInput(attrs={'readonly': 'readonly'})
2017-10-31 03:34:20 +00:00
}