Skip to content

Commit

Permalink
Related to #1144: Allow multiple status selections when filtering dev…
Browse files Browse the repository at this point in the history
…ice list
  • Loading branch information
jeremystretch committed May 8, 2017
1 parent 77247cc commit af4edff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions netbox/dcim/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from utilities.filters import NullableModelMultipleChoiceFilter, NumericInFilter
from .models import (
ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay,
DeviceBayTemplate, DeviceRole, DeviceType, IFACE_FF_LAG, Interface, InterfaceConnection, InterfaceTemplate,
Manufacturer, InventoryItem, Platform, PowerOutlet, PowerOutletTemplate, PowerPort, PowerPortTemplate, Rack,
RackGroup, RackReservation, RackRole, Region, Site, VIRTUAL_IFACE_TYPES,
DeviceBayTemplate, DeviceRole, DeviceType, STATUS_CHOICES, IFACE_FF_LAG, Interface, InterfaceConnection,
InterfaceTemplate, Manufacturer, InventoryItem, Platform, PowerOutlet, PowerOutletTemplate, PowerPort,
PowerPortTemplate, Rack, RackGroup, RackReservation, RackRole, Region, Site, VIRTUAL_IFACE_TYPES,
)


Expand Down Expand Up @@ -389,10 +389,13 @@ class DeviceFilter(CustomFieldFilterSet, django_filters.FilterSet):
method='_has_primary_ip',
label='Has a primary IP',
)
status = django_filters.MultipleChoiceFilter(
choices=STATUS_CHOICES
)

class Meta:
model = Device
fields = ['name', 'serial', 'asset_tag', 'status']
fields = ['name', 'serial', 'asset_tag']

def search(self, queryset, name, value):
if not value.strip():
Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ class DeviceFilterForm(BootstrapMixin, CustomFieldFilterForm):
to_field_name='slug',
null_option=(0, 'None'),
)
status = forms.ChoiceField(required=False, choices=device_status_choices)
status = forms.MultipleChoiceField(choices=device_status_choices, required=False)
mac_address = forms.CharField(required=False, label='MAC address')


Expand Down

0 comments on commit af4edff

Please sign in to comment.