mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 10:57:36 -02:30
Special handle host related_search_fields
Relates #7712 of ansible-tower. UI uses `related_search_fields` list to populate help text for resourse search, `ansible_facts` is searchable via UI but the general pickup logic would ignore it. So make it a corner case. Signed-off-by: Aaron Tan <jangsutsr@gmail.com>
This commit is contained in:
@@ -1925,7 +1925,17 @@ class InventoryJobTemplateList(SubListAPIView):
|
|||||||
return qs.filter(inventory=parent)
|
return qs.filter(inventory=parent)
|
||||||
|
|
||||||
|
|
||||||
class HostList(ListCreateAPIView):
|
class HostRelatedSearchMixin(object):
|
||||||
|
|
||||||
|
@property
|
||||||
|
def related_search_fields(self):
|
||||||
|
# Edge-case handle: https://github.com/ansible/ansible-tower/issues/7712
|
||||||
|
ret = super(HostRelatedSearchMixin, self).related_search_fields
|
||||||
|
ret.append('ansible_facts')
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
class HostList(HostRelatedSearchMixin, ListCreateAPIView):
|
||||||
|
|
||||||
always_allow_superuser = False
|
always_allow_superuser = False
|
||||||
model = Host
|
model = Host
|
||||||
@@ -1962,7 +1972,7 @@ class HostAnsibleFactsDetail(RetrieveAPIView):
|
|||||||
new_in_api_v2 = True
|
new_in_api_v2 = True
|
||||||
|
|
||||||
|
|
||||||
class InventoryHostsList(SubListCreateAttachDetachAPIView):
|
class InventoryHostsList(HostRelatedSearchMixin, SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
model = Host
|
model = Host
|
||||||
serializer_class = HostSerializer
|
serializer_class = HostSerializer
|
||||||
@@ -2230,7 +2240,9 @@ class GroupPotentialChildrenList(SubListAPIView):
|
|||||||
return qs.exclude(pk__in=except_pks)
|
return qs.exclude(pk__in=except_pks)
|
||||||
|
|
||||||
|
|
||||||
class GroupHostsList(ControlledByScmMixin, SubListCreateAttachDetachAPIView):
|
class GroupHostsList(HostRelatedSearchMixin,
|
||||||
|
ControlledByScmMixin,
|
||||||
|
SubListCreateAttachDetachAPIView):
|
||||||
''' the list of hosts directly below a group '''
|
''' the list of hosts directly below a group '''
|
||||||
|
|
||||||
model = Host
|
model = Host
|
||||||
@@ -2257,7 +2269,7 @@ class GroupHostsList(ControlledByScmMixin, SubListCreateAttachDetachAPIView):
|
|||||||
return super(GroupHostsList, self).create(request, *args, **kwargs)
|
return super(GroupHostsList, self).create(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class GroupAllHostsList(SubListAPIView):
|
class GroupAllHostsList(HostRelatedSearchMixin, SubListAPIView):
|
||||||
''' the list of all hosts below a group, even including subgroups '''
|
''' the list of all hosts below a group, even including subgroups '''
|
||||||
|
|
||||||
model = Host
|
model = Host
|
||||||
@@ -2621,7 +2633,7 @@ class InventorySourceNotificationTemplatesSuccessList(InventorySourceNotificatio
|
|||||||
relationship = 'notification_templates_success'
|
relationship = 'notification_templates_success'
|
||||||
|
|
||||||
|
|
||||||
class InventorySourceHostsList(SubListDestroyAPIView):
|
class InventorySourceHostsList(HostRelatedSearchMixin, SubListDestroyAPIView):
|
||||||
|
|
||||||
model = Host
|
model = Host
|
||||||
serializer_class = HostSerializer
|
serializer_class = HostSerializer
|
||||||
@@ -3977,7 +3989,7 @@ class JobEventChildrenList(SubListAPIView):
|
|||||||
view_name = _('Job Event Children List')
|
view_name = _('Job Event Children List')
|
||||||
|
|
||||||
|
|
||||||
class JobEventHostsList(SubListAPIView):
|
class JobEventHostsList(HostRelatedSearchMixin, SubListAPIView):
|
||||||
|
|
||||||
model = Host
|
model = Host
|
||||||
serializer_class = HostSerializer
|
serializer_class = HostSerializer
|
||||||
|
|||||||
Reference in New Issue
Block a user