Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #37 from openwisp/search
Browse files Browse the repository at this point in the history
[admin] Added search fields and list displays
  • Loading branch information
nemesifier committed Jul 20, 2018
2 parents 99954e4 + eeb6e83 commit 1877f1d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions django_ipam/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class AbstractSubnetAdmin(TimeReadonlyAdminMixin, ModelAdmin):
change_form_template = "admin/django-ipam/subnet/change_form.html"
change_list_template = "admin/django-ipam/subnet/change_list.html"
app_name = "django_ipam"
list_display = ('name', 'subnet', 'master_subnet', 'description')
search_fields = ['subnet', 'name']

def change_view(self, request, object_id, form_url="", extra_context=None):
instance = Subnet.objects.get(pk=object_id)
Expand Down Expand Up @@ -111,6 +113,9 @@ def __init__(self, *args, **kwargs):
class AbstractIpAddressAdmin(TimeReadonlyAdminMixin, ModelAdmin):
form = IpAddressAdminForm
change_form_template = "admin/django-ipam/ip_address/change_form.html"
list_display = ('ip_address', 'subnet', 'description')
list_filter = ('subnet',)
search_fields = ['ip_address']

class Media:
js = ('django-ipam/js/ip-request.js',)
Expand Down
2 changes: 1 addition & 1 deletion django_ipam/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CsvImportException(Exception):


class AbstractSubnet(TimeStampedEditableModel):
name = models.CharField(max_length=100, blank=True)
name = models.CharField(max_length=100, blank=True, db_index=True)
subnet = NetworkField(db_index=True,
help_text=_('Subnet in CIDR notation, eg: "10.0.0.0/24" '
'for IPv4 and "fdb6:21b:a477::9f7/64" for IPv6'))
Expand Down
18 changes: 18 additions & 0 deletions django_ipam/migrations/0003_auto_20180719_1849.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.0.5 on 2018-07-19 18:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('django_ipam', '0002_auto_20180713_0911'),
]

operations = [
migrations.AlterField(
model_name='subnet',
name='name',
field=models.CharField(blank=True, db_index=True, max_length=100),
),
]

0 comments on commit 1877f1d

Please sign in to comment.