forked from Azimut-Prod/azimut-gestion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
29 lines (20 loc) · 875 Bytes
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from django.forms import ModelForm
from servers.models import Server, SshKey
class ServerForm(ModelForm):
class Meta:
model = Server
exclude = ()
def __init__(self, *args, **kwargs):
super(ServerForm, self).__init__(*args, **kwargs)
self.fields["vm_host"].queryset = Server.objects.filter(is_vm=False).order_by('name').exclude(pk=kwargs['instance'].pk)
self.fields["ngnix_server"].queryset = Server.objects.filter(is_vm=True).order_by('name').filter(vm_host=kwargs['instance'])
class ServerSshKey(ModelForm):
class Meta:
model = SshKey
exclude = ('server',)
class SshKeyForm(ModelForm):
class Meta:
model = SshKey
def __init__(self, *args, **kwargs):
super(SshKeyForm, self).__init__(*args, **kwargs)
self.fields["server"].queryset = Server.objects.order_by('name')