mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
Add autocomplete on machine, interface edit forms
This commit is contained in:
parent
b1fcfc306a
commit
7dfaf6ff65
3 changed files with 23 additions and 2 deletions
|
@ -104,7 +104,10 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
||||||
url="/machines/machinetype-autocomplete",
|
url="/machines/machinetype-autocomplete",
|
||||||
),
|
),
|
||||||
"ipv4": AutocompleteModelMixin(
|
"ipv4": AutocompleteModelMixin(
|
||||||
url="/machines/ipv4-autocomplete",
|
url="/machines/iplist-autocomplete", forward=['machine_type'],
|
||||||
|
attrs={
|
||||||
|
'data-placeholder': 'Automatic assigment. Type to choose specific ip.',
|
||||||
|
}
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,4 +162,5 @@ urlpatterns = [
|
||||||
url(r'^extension-autocomplete/$', views_autocomplete.ExtensionAutocomplete.as_view(), name='extension-autocomplete',),
|
url(r'^extension-autocomplete/$', views_autocomplete.ExtensionAutocomplete.as_view(), name='extension-autocomplete',),
|
||||||
url(r'^domain-autocomplete/$', views_autocomplete.DomainAutocomplete.as_view(), name='domain-autocomplete',),
|
url(r'^domain-autocomplete/$', views_autocomplete.DomainAutocomplete.as_view(), name='domain-autocomplete',),
|
||||||
url(r'^ouvertureportlist-autocomplete/$', views_autocomplete.OuverturePortListAutocomplete.as_view(), name='ouvertureportlist-autocomplete',),
|
url(r'^ouvertureportlist-autocomplete/$', views_autocomplete.OuverturePortListAutocomplete.as_view(), name='ouvertureportlist-autocomplete',),
|
||||||
|
url(r'^iplist-autocomplete/$', views_autocomplete.IpListAutocomplete.as_view(), name='iplist-autocomplete',),
|
||||||
]
|
]
|
||||||
|
|
|
@ -41,7 +41,8 @@ from .models import (
|
||||||
MachineType,
|
MachineType,
|
||||||
Extension,
|
Extension,
|
||||||
Domain,
|
Domain,
|
||||||
OuverturePortList
|
OuverturePortList,
|
||||||
|
IpList
|
||||||
)
|
)
|
||||||
|
|
||||||
from re2o.mixins import AutocompleteViewMixin
|
from re2o.mixins import AutocompleteViewMixin
|
||||||
|
@ -88,3 +89,19 @@ class InterfaceAutocomplete(AutocompleteViewMixin):
|
||||||
)
|
)
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class IpListAutocomplete(AutocompleteViewMixin):
|
||||||
|
obj_type = IpList
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
machine_type = self.forwarded.get('machine_type', None)
|
||||||
|
qs = self.obj_type.objects.filter(interface__isnull=True)
|
||||||
|
if machine_type:
|
||||||
|
qs = qs.filter(ip_type__machinetype__id=machine_type)
|
||||||
|
if self.q:
|
||||||
|
qs = qs.filter(
|
||||||
|
Q(ipv4__startswith=self.q)
|
||||||
|
)
|
||||||
|
|
||||||
|
return qs
|
||||||
|
|
Loading…
Reference in a new issue