diff --git a/README.rst b/README.rst index e2dd5d7..76e36b1 100644 --- a/README.rst +++ b/README.rst @@ -25,7 +25,7 @@ to install the Netbox SLM plugin: 1. Add ``netbox_slm`` to the ``PLUGINS`` list in ``configuration/extra.py``. -2. Create a ``plugin_requirements.txt`` with ``netbox-slm==0.99`` as +2. Create a ``plugin_requirements.txt`` with ``netbox-slm==1.01`` as contents. 3. Create a ``Dockerfile-SLM`` with contents: diff --git a/netbox_slm/__init__.py b/netbox_slm/__init__.py index e25b235..9c3628a 100644 --- a/netbox_slm/__init__.py +++ b/netbox_slm/__init__.py @@ -5,7 +5,7 @@ class SLMConfig(PluginConfig): name = 'netbox_slm' verbose_name = 'Software Lifecycle Management' description = 'Software Lifecycle Management' - version = '0.99' + version = '1.01' author = 'Hedde van der Heide' author_email = 'hedde.vanderheide@ictu.nl' base_url = 'slm' diff --git a/netbox_slm/admin.py b/netbox_slm/admin.py index 1959cdc..e69de29 100644 --- a/netbox_slm/admin.py +++ b/netbox_slm/admin.py @@ -1,14 +0,0 @@ -from django.contrib import admin -from netbox_slm.models import SoftwareProduct, SoftwareProductVersion - - -class SoftwareProductVersionInline(admin.TabularInline): - model = SoftwareProductVersion - fields = ('name',) - extra = 0 - - -@admin.register(SoftwareProduct) -class SoftwareProductAdmin(admin.ModelAdmin): - list_display = ('name',) - inlines = (SoftwareProductVersionInline,) diff --git a/netbox_slm/filtersets.py b/netbox_slm/filtersets.py index 31ca9e1..ae5a024 100644 --- a/netbox_slm/filtersets.py +++ b/netbox_slm/filtersets.py @@ -1,3 +1,5 @@ +from django.db.models import Q + from netbox.filtersets import NetBoxModelFilterSet from netbox_slm.models import * @@ -8,6 +10,14 @@ class SoftwareProductFilterSet(NetBoxModelFilterSet): model = SoftwareProduct fields = tuple() + def search(self, queryset, name, value): + """Perform the filtered search.""" + if not value.strip(): + return queryset + qs_filter = Q(name__icontains=value) | \ + Q(manufacturer__name__icontains=value) + return queryset.filter(qs_filter) + class SoftwareProductVersionFilterSet(NetBoxModelFilterSet): """Filter capabilities for SoftwareProductVersion instances.""" @@ -15,9 +25,27 @@ class SoftwareProductVersionFilterSet(NetBoxModelFilterSet): model = SoftwareProductVersion fields = tuple() + def search(self, queryset, name, value): + """Perform the filtered search.""" + if not value.strip(): + return queryset + qs_filter = Q(name__icontains=value) | \ + Q(software_product__name__icontains=value) | \ + Q(software_product__manufacturer__name__icontains=value) + return queryset.filter(qs_filter) + class SoftwareProductInstallationFilterSet(NetBoxModelFilterSet): """Filter capabilities for SoftwareProductInstallation instances.""" class Meta: model = SoftwareProductInstallation fields = tuple() + + def search(self, queryset, name, value): + """Perform the filtered search.""" + if not value.strip(): + return queryset + qs_filter = Q(software_product__name__icontains=value) | \ + Q(software_product__manufacturer__name__icontains=value) | \ + Q(version__name__icontains=value) + return queryset.filter(qs_filter) diff --git a/netbox_slm/forms.py b/netbox_slm/forms.py index 12c9814..9870ed9 100644 --- a/netbox_slm/forms.py +++ b/netbox_slm/forms.py @@ -1,5 +1,4 @@ from django import forms -from django.db.models import Q from django.urls import reverse_lazy from django.utils.translation import gettext as _ @@ -12,7 +11,7 @@ from netbox.forms import ( ) from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation from utilities.forms import ( - DynamicModelChoiceField, APISelect, TagFilterField + DynamicModelChoiceField, APISelect, TagFilterField, ChoiceField ) from virtualization.models import VirtualMachine @@ -38,14 +37,6 @@ class SoftwareProductFilterForm(NetBoxModelFilterSetForm): tag = TagFilterField(model) - def search(self, queryset, name, value): - """Perform the filtered search.""" - if not value.strip(): - return queryset - qs_filter = Q(name__icontains=value) | \ - Q(manufacturer__name__icontains=value) - return queryset.filter(qs_filter) - class SoftwareProductCSVForm(NetBoxModelCSVForm): class Meta: @@ -88,15 +79,6 @@ class SoftwareProductVersionFilterForm(NetBoxModelFilterSetForm): tag = TagFilterField(model) - def search(self, queryset, name, value): - """Perform the filtered search.""" - if not value.strip(): - return queryset - qs_filter = Q(name__icontains=value) | \ - Q(software_product__name__icontains=value) | \ - Q(software_product__manufacturer__name__icontains=value) - return queryset.filter(qs_filter) - class SoftwareProductVersionCSVForm(NetBoxModelCSVForm): class Meta: @@ -165,20 +147,11 @@ class SoftwareProductInstallationForm(NetBoxModelForm): class SoftwareProductInstallationFilterForm(NetBoxModelFilterSetForm): model = SoftwareProductInstallation fieldsets = ( - (None, ('q', 'tag')), + (None, ('q', 'tag',)), ) tag = TagFilterField(model) - def search(self, queryset, name, value): - """Perform the filtered search.""" - if not value.strip(): - return queryset - qs_filter = Q(software_product__name__icontains=value) | \ - Q(software_product__manufacturer__name__icontains=value) | \ - Q(version__name__icontains=value) - return queryset.filter(qs_filter) - class SoftwareProductInstallationCSVForm(NetBoxModelCSVForm): class Meta: diff --git a/setup.cfg b/setup.cfg index d290fa1..3a2671e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = netbox-slm -version = 0.99 +version = 1.01 description = Software Lifecycle Management Netbox Plugin. # long_description = file: README.rst # long_description_content_type='text/x-rst'