diff --git a/nautobot_device_lifecycle_mgmt/filters.py b/nautobot_device_lifecycle_mgmt/filters.py index 99ecbdcc..526ba33e 100644 --- a/nautobot_device_lifecycle_mgmt/filters.py +++ b/nautobot_device_lifecycle_mgmt/filters.py @@ -110,6 +110,7 @@ class SoftwareLCMFilterSet(django_filters.FilterSet): release_date = django_filters.DateTimeFromToRangeFilter() end_of_support = django_filters.DateTimeFromToRangeFilter() + tag = TagFilter() class Meta: """Meta attributes for filter.""" @@ -211,6 +212,7 @@ class ValidatedSoftwareLCMFilterSet(django_filters.FilterSet): start = django_filters.DateTimeFromToRangeFilter() end = django_filters.DateTimeFromToRangeFilter() valid = django_filters.BooleanFilter(method="valid_search", label="Currently valid") + tag = TagFilter() class Meta: """Meta attributes for filter.""" @@ -276,7 +278,6 @@ def inventory_item(self, queryset, name, value): # pylint: disable=unused-argum if not value: return queryset - print(value) inventory_items = InventoryItem.objects.filter(id=value) if inventory_items.count() != 1: diff --git a/nautobot_device_lifecycle_mgmt/forms.py b/nautobot_device_lifecycle_mgmt/forms.py index be02f827..f5589604 100644 --- a/nautobot_device_lifecycle_mgmt/forms.py +++ b/nautobot_device_lifecycle_mgmt/forms.py @@ -194,6 +194,7 @@ class Meta: class SoftwareLCMFilterForm(BootstrapMixin, forms.ModelForm): """Filter form to filter searches for SoftwareLCM.""" + model = SoftwareLCM q = forms.CharField( required=False, label="Search", @@ -207,6 +208,7 @@ class SoftwareLCMFilterForm(BootstrapMixin, forms.ModelForm): release_date_after = forms.DateField(label="Release Date After", required=False, widget=DatePicker()) end_of_support_before = forms.DateField(label="End of Software Support Before", required=False, widget=DatePicker()) end_of_support_after = forms.DateField(label="End of Software Support After", required=False, widget=DatePicker()) + tag = TagFilterField(model) class Meta: """Meta attributes.""" @@ -226,6 +228,7 @@ class Meta: "image_file_checksum", "long_term_support", "pre_release", + "tag", ] widgets = { @@ -303,12 +306,13 @@ def clean(self): class ValidatedSoftwareLCMFilterForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): """Filter form to filter searches for SoftwareLCM.""" + model = ValidatedSoftwareLCM q = forms.CharField( required=False, label="Search", help_text="Search for start or end date of validity.", ) - software = DynamicModelChoiceField(required=False, queryset=SoftwareLCM.objects.all()) + software = DynamicModelMultipleChoiceField(required=False, queryset=SoftwareLCM.objects.all()) devices = DynamicModelMultipleChoiceField( queryset=Device.objects.all(), to_field_name="name", @@ -340,6 +344,7 @@ class ValidatedSoftwareLCMFilterForm(BootstrapMixin, CustomFieldModelForm, Relat valid = forms.BooleanField( label="Valid Now", required=False, widget=StaticSelect2(choices=BOOLEAN_WITH_BLANK_CHOICES) ) + tag = TagFilterField(model) class Meta: """Meta attributes.""" @@ -357,6 +362,7 @@ class Meta: "valid", "start_before", "start_after", + "tag", ] diff --git a/nautobot_device_lifecycle_mgmt/tables.py b/nautobot_device_lifecycle_mgmt/tables.py index 3eb37fa3..10ec205a 100644 --- a/nautobot_device_lifecycle_mgmt/tables.py +++ b/nautobot_device_lifecycle_mgmt/tables.py @@ -84,6 +84,7 @@ class SoftwareLCMTable(BaseTable): device_platform = tables.TemplateColumn("{{ record.device_platform }}") long_term_support = BooleanColumn() pre_release = BooleanColumn() + tags = TagColumn() actions = ButtonsColumn(SoftwareLCM, buttons=("edit", "delete")) class Meta(BaseTable.Meta): # pylint: disable=too-few-public-methods @@ -91,6 +92,19 @@ class Meta(BaseTable.Meta): # pylint: disable=too-few-public-methods model = SoftwareLCM fields = ( + "pk", + "name", + "version", + "alias", + "device_platform", + "release_date", + "end_of_support", + "long_term_support", + "pre_release", + "tags", + "actions", + ) + default_columns = ( "pk", "name", "version", @@ -118,14 +132,26 @@ class ValidatedSoftwareLCMTable(BaseTable): ) valid = BooleanColumn(verbose_name="Valid Now", orderable=False) software = tables.LinkColumn(verbose_name="Software") - actions = ButtonsColumn(ValidatedSoftwareLCM, buttons=("edit", "delete")) preferred = BooleanColumn() + tags = TagColumn() + actions = ButtonsColumn(ValidatedSoftwareLCM, buttons=("edit", "delete")) class Meta(BaseTable.Meta): # pylint: disable=too-few-public-methods """Meta attributes.""" model = ValidatedSoftwareLCM fields = ( + "pk", + "name", + "software", + "start", + "end", + "valid", + "preferred", + "tags", + "actions", + ) + default_columns = ( "pk", "name", "software",