Skip to content

Commit

Permalink
[chores] Improvements to IpAddressAdmin
Browse files Browse the repository at this point in the history
- show organization field first
- rename the org filter to IpOrganizationFiltger
  to make it clear that it's the organization filter for Ip
- added title attribute to subnet filter
  • Loading branch information
nemesifier committed Dec 6, 2022
1 parent a290a86 commit 80b3970
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions openwisp_ipam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .api.views import HostsSet
from .base.forms import IpAddressImportForm
from .base.models import CsvImportException
from .filters import SubnetFilter, SubnetOrganizationFilter
from .filters import IpOrganizationFilter, SubnetFilter

Subnet = swapper.load_model('openwisp_ipam', 'Subnet')
IpAddress = swapper.load_model('openwisp_ipam', 'IpAddress')
Expand Down Expand Up @@ -219,7 +219,7 @@ class IpAddressAdmin(
form = IpAddressAdminForm
change_form_template = 'admin/openwisp-ipam/ip_address/change_form.html'
list_display = ['ip_address', 'subnet', 'organization', 'created', 'modified']
list_filter = [SubnetFilter, SubnetOrganizationFilter]
list_filter = [IpOrganizationFilter, SubnetFilter]
search_fields = ['ip_address']
autocomplete_fields = ['subnet']
multitenant_parent = 'subnet'
Expand Down
4 changes: 3 additions & 1 deletion openwisp_ipam/filters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
from openwisp_users.multitenancy import MultitenantRelatedOrgFilter
from swapper import load_model

Expand All @@ -7,8 +8,9 @@
class SubnetFilter(MultitenantRelatedOrgFilter):
field_name = 'subnet'
parameter_name = 'subnet_id'
title = _('subnet')


class SubnetOrganizationFilter(MultitenantRelatedOrgFilter):
class IpOrganizationFilter(MultitenantRelatedOrgFilter):
parameter_name = 'subnet__organization'
rel_model = Subnet

0 comments on commit 80b3970

Please sign in to comment.