|
@@ -5,7 +5,7 @@ from django.db.models import Count, Q
|
|
|
|
|
|
from ipam.models import IPAddress
|
|
from ipam.models import IPAddress
|
|
from utilities.forms import (
|
|
from utilities.forms import (
|
|
- APISelect, BootstrapMixin, BulkImportForm, CommentField, ConfirmationForm, CSVDataField, ExpandableNameField,
|
|
|
|
|
|
+ APISelect, BootstrapMixin, BulkImportForm, CommentField, CSVDataField, ExpandableNameField,
|
|
FlexibleModelChoiceField, Livesearch, SelectWithDisabled, SmallTextarea, SlugField,
|
|
FlexibleModelChoiceField, Livesearch, SelectWithDisabled, SmallTextarea, SlugField,
|
|
)
|
|
)
|
|
|
|
|
|
@@ -85,10 +85,6 @@ class RackGroupForm(forms.ModelForm, BootstrapMixin):
|
|
fields = ['site', 'name', 'slug']
|
|
fields = ['site', 'name', 'slug']
|
|
|
|
|
|
|
|
|
|
-class RackGroupBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=RackGroup.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def rackgroup_site_choices():
|
|
def rackgroup_site_choices():
|
|
site_choices = Site.objects.annotate(rack_count=Count('rack_groups'))
|
|
site_choices = Site.objects.annotate(rack_count=Count('rack_groups'))
|
|
return [(s.slug, u'{} ({})'.format(s.name, s.rack_count)) for s in site_choices]
|
|
return [(s.slug, u'{} ({})'.format(s.name, s.rack_count)) for s in site_choices]
|
|
@@ -169,10 +165,6 @@ class RackBulkEditForm(forms.Form, BootstrapMixin):
|
|
comments = CommentField()
|
|
comments = CommentField()
|
|
|
|
|
|
|
|
|
|
-class RackBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=Rack.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def rack_site_choices():
|
|
def rack_site_choices():
|
|
site_choices = Site.objects.annotate(rack_count=Count('racks'))
|
|
site_choices = Site.objects.annotate(rack_count=Count('racks'))
|
|
return [(s.slug, u'{} ({})'.format(s.name, s.rack_count)) for s in site_choices]
|
|
return [(s.slug, u'{} ({})'.format(s.name, s.rack_count)) for s in site_choices]
|
|
@@ -202,10 +194,6 @@ class ManufacturerForm(forms.ModelForm, BootstrapMixin):
|
|
fields = ['name', 'slug']
|
|
fields = ['name', 'slug']
|
|
|
|
|
|
|
|
|
|
-class ManufacturerBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=Manufacturer.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#
|
|
#
|
|
# Device types
|
|
# Device types
|
|
#
|
|
#
|
|
@@ -225,10 +213,6 @@ class DeviceTypeBulkEditForm(forms.Form, BootstrapMixin):
|
|
u_height = forms.IntegerField(min_value=1, required=False)
|
|
u_height = forms.IntegerField(min_value=1, required=False)
|
|
|
|
|
|
|
|
|
|
-class DeviceTypeBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=DeviceType.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def devicetype_manufacturer_choices():
|
|
def devicetype_manufacturer_choices():
|
|
manufacturer_choices = Manufacturer.objects.annotate(devicetype_count=Count('device_types'))
|
|
manufacturer_choices = Manufacturer.objects.annotate(devicetype_count=Count('device_types'))
|
|
return [(m.slug, u'{} ({})'.format(m.name, m.devicetype_count)) for m in manufacturer_choices]
|
|
return [(m.slug, u'{} ({})'.format(m.name, m.devicetype_count)) for m in manufacturer_choices]
|
|
@@ -251,10 +235,6 @@ class ConsolePortTemplateForm(forms.ModelForm, BootstrapMixin):
|
|
fields = ['name_pattern']
|
|
fields = ['name_pattern']
|
|
|
|
|
|
|
|
|
|
-class ConsolePortTemplateBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=ConsolePortTemplate.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
class ConsoleServerPortTemplateForm(forms.ModelForm, BootstrapMixin):
|
|
class ConsoleServerPortTemplateForm(forms.ModelForm, BootstrapMixin):
|
|
name_pattern = ExpandableNameField(label='Name')
|
|
name_pattern = ExpandableNameField(label='Name')
|
|
|
|
|
|
@@ -263,10 +243,6 @@ class ConsoleServerPortTemplateForm(forms.ModelForm, BootstrapMixin):
|
|
fields = ['name_pattern']
|
|
fields = ['name_pattern']
|
|
|
|
|
|
|
|
|
|
-class ConsoleServerPortTemplateBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=ConsoleServerPortTemplate.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
class PowerPortTemplateForm(forms.ModelForm, BootstrapMixin):
|
|
class PowerPortTemplateForm(forms.ModelForm, BootstrapMixin):
|
|
name_pattern = ExpandableNameField(label='Name')
|
|
name_pattern = ExpandableNameField(label='Name')
|
|
|
|
|
|
@@ -311,10 +287,6 @@ class DeviceRoleForm(forms.ModelForm, BootstrapMixin):
|
|
fields = ['name', 'slug', 'color']
|
|
fields = ['name', 'slug', 'color']
|
|
|
|
|
|
|
|
|
|
-class DeviceRoleBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=DeviceRole.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#
|
|
#
|
|
# Platforms
|
|
# Platforms
|
|
#
|
|
#
|
|
@@ -327,10 +299,6 @@ class PlatformForm(forms.ModelForm, BootstrapMixin):
|
|
fields = ['name', 'slug']
|
|
fields = ['name', 'slug']
|
|
|
|
|
|
|
|
|
|
-class PlatformBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=Platform.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#
|
|
#
|
|
# Devices
|
|
# Devices
|
|
#
|
|
#
|
|
@@ -550,10 +518,6 @@ class DeviceBulkEditForm(forms.Form, BootstrapMixin):
|
|
serial = forms.CharField(max_length=50, required=False, label='Serial Number')
|
|
serial = forms.CharField(max_length=50, required=False, label='Serial Number')
|
|
|
|
|
|
|
|
|
|
-class DeviceBulkDeleteForm(ConfirmationForm):
|
|
|
|
- pk = forms.ModelMultipleChoiceField(queryset=Device.objects.all(), widget=forms.MultipleHiddenInput)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def device_site_choices():
|
|
def device_site_choices():
|
|
site_choices = Site.objects.annotate(device_count=Count('racks__devices'))
|
|
site_choices = Site.objects.annotate(device_count=Count('racks__devices'))
|
|
return [(s.slug, u'{} ({})'.format(s.name, s.device_count)) for s in site_choices]
|
|
return [(s.slug, u'{} ({})'.format(s.name, s.device_count)) for s in site_choices]
|