mirror of
https://github.com/ansible/awx.git
synced 2026-05-22 08:17:39 -02:30
Remove search term separators
Relates #7656 in ansible-tower. We have been using comma `,` and space ` ` to separate search terms in query string `<field_name>__search=<search terms>`, however in general we can always use `&` to achieve separation like `<field_name>__search=<search term 1>&<field_name>__search=<search term 2>&...`. Using specific delimiters makes it impossible for search terms to contain those delimiters, so they are better off being removed. Signed-off-by: Aaron Tan <jangsutsr@gmail.com>
This commit is contained in:
@@ -242,11 +242,10 @@ class FieldLookupBackend(BaseFilterBackend):
|
||||
# Search across related objects.
|
||||
if key.endswith('__search'):
|
||||
for value in values:
|
||||
for search_term in force_text(value).replace(',', ' ').split():
|
||||
search_value, new_keys = self.value_to_python(queryset.model, key, search_term)
|
||||
assert isinstance(new_keys, list)
|
||||
for new_key in new_keys:
|
||||
search_filters.append((new_key, search_value))
|
||||
search_value, new_keys = self.value_to_python(queryset.model, key, force_text(value))
|
||||
assert isinstance(new_keys, list)
|
||||
for new_key in new_keys:
|
||||
search_filters.append((new_key, search_value))
|
||||
continue
|
||||
|
||||
# Custom chain__ and or__ filters, mutually exclusive (both can
|
||||
|
||||
@@ -60,6 +60,10 @@ _Added in AWX 1.4_
|
||||
|
||||
?related__search=findme
|
||||
|
||||
Note: If you want to provide more than one search terms, please use multiple
|
||||
search fields with the same key, like `?related__search=foo&related__search=bar`,
|
||||
All search terms with the same key will be ORed together.
|
||||
|
||||
## Filtering
|
||||
|
||||
Any additional query string parameters may be used to filter the list of
|
||||
|
||||
Reference in New Issue
Block a user