Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ztobar add tags view 114 #128

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nautobot_device_lifecycle_mgmt/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion nautobot_device_lifecycle_mgmt/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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."""
Expand All @@ -226,6 +228,7 @@ class Meta:
"image_file_checksum",
"long_term_support",
"pre_release",
"tag",
]

widgets = {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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."""
Expand All @@ -357,6 +362,7 @@ class Meta:
"valid",
"start_before",
"start_after",
"tag",
]


Expand Down
28 changes: 27 additions & 1 deletion nautobot_device_lifecycle_mgmt/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,27 @@ 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
"""Meta attributes."""

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",
Expand Down Expand Up @@ -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",
Expand Down