Commit 98c460a0 by Guba Sándor

add form

parent 7da7ef22
...@@ -56,6 +56,9 @@ from django.utils.translation import string_concat ...@@ -56,6 +56,9 @@ from django.utils.translation import string_concat
from .virtvalidator import domain_validator from .virtvalidator import domain_validator
from dashboard.models import ConnectCommand
from vm.models.instance import ACCESS_METHODS
LANGUAGES_WITH_CODE = ((l[0], string_concat(l[1], " (", l[0], ")")) LANGUAGES_WITH_CODE = ((l[0], string_concat(l[1], " (", l[0], ")"))
for l in LANGUAGES) for l in LANGUAGES)
...@@ -1037,6 +1040,39 @@ class UserKeyForm(forms.ModelForm): ...@@ -1037,6 +1040,39 @@ class UserKeyForm(forms.ModelForm):
return super(UserKeyForm, self).clean() return super(UserKeyForm, self).clean()
class ConnectCommandForm(forms.ModelForm):
access_method = forms.ChoiceField(ACCESS_METHODS, required=True,
label=_('Access method'))
application = forms.CharField(required=False, label=_('Application'),
help_text=_('This will be the value of the '
'%(app)s parameter.'))
template = forms.CharField(
label=_('Template'), required=True,
help_text=_('This will be the connection command template. '
'Available parameters are: username, '
'host, port, password, app.'
'Example: %(app)s -p %(password)s %(host)s'))
class Meta:
fields = ('access_method', 'application', 'template')
model = ConnectCommand
@property
def helper(self):
helper = FormHelper()
helper.add_input(Submit("submit", _("Save")))
return helper
def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user", None)
super(ConnectCommandForm, self).__init__(*args, **kwargs)
def clean(self):
if self.user:
self.instance.user = self.user
return super(ConnectCommandForm, self).clean()
class TraitsForm(forms.ModelForm): class TraitsForm(forms.ModelForm):
class Meta: class Meta:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment