Skip to content

Commit 96b2b2f

Browse files
Merge pull request #361 from nautobot/u/defiantearth/NAPPS-724/3.0-QA-review-fixes
Fixed issues found in QA review
2 parents db051a0 + 4c867b3 commit 96b2b2f

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

changes/361.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restored missing action buttons on PolicyRule and NATPolicyRule tables and fixed an issue with the UserObject q filter.

nautobot_firewall_models/filters.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,16 @@ class Meta:
125125
fields = [i.name for i in model._meta.get_fields() if not isinstance(i, GenericRelation)]
126126

127127

128-
class UserObjectFilterSet(BaseFilterSet, NautobotFilterSet):
128+
class UserObjectFilterSet(NautobotFilterSet):
129129
"""Filter for UserObject."""
130130

131+
q = SearchFilter(
132+
filter_predicates={
133+
"name": "icontains",
134+
"username": "icontains",
135+
}
136+
)
137+
131138
class Meta:
132139
"""Meta attributes for filter."""
133140

nautobot_firewall_models/tables.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class Meta(BaseTable.Meta):
198198
"request_id",
199199
"log",
200200
"status",
201+
"actions",
201202
)
202203
default_columns = (
203204
"pk",
@@ -219,6 +220,7 @@ class Meta(BaseTable.Meta):
219220
"action",
220221
"log",
221222
"status",
223+
"actions",
222224
)
223225

224226

@@ -277,6 +279,7 @@ class Meta(BaseTable.Meta):
277279
"description",
278280
"log",
279281
"status",
282+
"actions",
280283
)
281284
default_columns = (
282285
# pylint: disable=duplicate-code
@@ -303,6 +306,7 @@ class Meta(BaseTable.Meta):
303306
"remark",
304307
"log",
305308
"status",
309+
"actions",
306310
)
307311

308312

nautobot_firewall_models/tests/test_filters.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from nautobot.ipam.models import IPAddress, Namespace, Prefix
1010

1111
from nautobot_firewall_models import filters, models
12+
from nautobot_firewall_models.models import UserObject
1213

1314
from .fixtures import create_capirca_env
1415

@@ -128,3 +129,41 @@ def setUpTestData(cls):
128129
application_object_groups[0].application_objects.set([application_objects[0]])
129130
application_object_groups[1].application_objects.set([application_objects[1]])
130131
application_object_groups[2].application_objects.set([application_objects[2]])
132+
133+
134+
class UserObjectTestCase(FilterTestCases.FilterTestCase):
135+
"""Test filtering operations for ApplicationObject Model."""
136+
137+
queryset = models.UserObject.objects.all()
138+
filterset = filters.UserObjectFilterSet
139+
140+
@classmethod
141+
def setUpTestData(cls):
142+
"""Set up test data."""
143+
144+
status_active = Status.objects.get(name="Active")
145+
UserObject.objects.get_or_create(
146+
username="user1",
147+
name="Bob",
148+
status=status_active,
149+
)
150+
UserObject.objects.get_or_create(
151+
username="user2",
152+
name="Fred",
153+
status=status_active,
154+
)
155+
UserObject.objects.get_or_create(
156+
username="user3",
157+
name="Tom",
158+
status=status_active,
159+
)
160+
161+
def test_q_filter_name(self):
162+
"""Test q filter on name field"""
163+
params = {"q": "Bob"}
164+
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
165+
166+
def test_q_filter_username(self):
167+
"""Test q filter on username field"""
168+
params = {"q": "user2"}
169+
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)

0 commit comments

Comments
 (0)