Skip to content

Commit

Permalink
Merge pull request #203 from netbox-community/dev
Browse files Browse the repository at this point in the history
1.6.1 release
  • Loading branch information
cruse1977 authored Jun 13, 2024
2 parents 4586ceb + 0b66c84 commit a2e7a2b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Each Plugin Version listed below has been tested with its corresponding NetBox V

| NetBox Version | Plugin Version |
|:--------------:|:--------------:|
| >= 4.0.2 | 1.6.0 |
| >= 4.0.2 | 1.6.1 |
| 3.7 | 1.5.0 |
| 3.6 | 1.4.0 |
| 3.5 | 1.3.0 |
Expand Down
24 changes: 22 additions & 2 deletions netbox_acls/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
when filtering the sites list by status or region, for instance.
"""
import django_filters
from dcim.models import Device, Interface, VirtualChassis
from dcim.models import Device, Interface, Region, Site, SiteGroup, VirtualChassis
from django.db.models import Q
from netbox.filtersets import NetBoxModelFilterSet
from virtualization.models import VirtualMachine, VMInterface
Expand All @@ -22,7 +22,24 @@ class AccessListFilterSet(NetBoxModelFilterSet):
"""
Define the filter set for the django model AccessList.
"""

region = django_filters.ModelMultipleChoiceFilter(
field_name="device__site__region",
queryset=Region.objects.all(),
to_field_name="id",
label="Region",
)
site_group = django_filters.ModelMultipleChoiceFilter(
field_name="device__site__group",
queryset=SiteGroup.objects.all(),
to_field_name="id",
label="Site Group",
)
site = django_filters.ModelMultipleChoiceFilter(
field_name="device__site",
queryset=Site.objects.all(),
to_field_name="id",
label="Site",
)
device = django_filters.ModelMultipleChoiceFilter(
field_name="device__name",
queryset=Device.objects.all(),
Expand Down Expand Up @@ -75,6 +92,9 @@ class Meta:
"type",
"default_action",
"comments",
"site",
"site_group",
"region",
)

def search(self, queryset, name, value):
Expand Down
17 changes: 11 additions & 6 deletions netbox_acls/forms/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from dcim.models import Device, Interface, Region, Site, SiteGroup, VirtualChassis
from django import forms
from django.utils.translation import gettext as _
from ipam.models import Prefix
from netbox.forms import NetBoxModelFilterSetForm
from utilities.forms.fields import (
Expand All @@ -14,6 +15,7 @@
from utilities.forms.utils import add_blank_choice
from virtualization.models import VirtualMachine, VMInterface


from ..choices import (
ACLActionChoices,
ACLAssignmentDirectionChoices,
Expand Down Expand Up @@ -56,22 +58,25 @@ class AccessListFilterForm(NetBoxModelFilterSetForm):
required=False,
query_params={"region_id": "$region", "group_id": "$site_group"},
)
device = DynamicModelChoiceField(
device_id = DynamicModelChoiceField(
queryset=Device.objects.all(),
query_params={
"region_id": "$region",
"group_id": "$site_group",
"site_id": "$site",
},
required=False,
label=_("Device",),
)
virtual_machine = DynamicModelChoiceField(
virtual_machine_id = DynamicModelChoiceField(
queryset=VirtualMachine.objects.all(),
required=False,
label=_("Virtual Machine",)
)
virtual_chassis = DynamicModelChoiceField(
virtual_chassis_id = DynamicModelChoiceField(
queryset=VirtualChassis.objects.all(),
required=False,
label=_("Virtual Chassis",)
)
type = forms.ChoiceField(
choices=add_blank_choice(ACLTypeChoices),
Expand All @@ -92,9 +97,9 @@ class AccessListFilterForm(NetBoxModelFilterSetForm):
"region",
"site_group",
"site",
"device",
"virtual_chassis",
"virtual_machine",
"device_id",
"virtual_chassis_id",
"virtual_machine_id",
),
),
("ACL Details", ("type", "default_action")),
Expand Down
2 changes: 1 addition & 1 deletion netbox_acls/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.0"
__version__ = "1.6.1"

0 comments on commit a2e7a2b

Please sign in to comment.