Skip to content

Commit

Permalink
Merge pull request #168 from salopensource/search_facts
Browse files Browse the repository at this point in the history
Search facts
  • Loading branch information
grahamgilbert authored Jan 5, 2018
2 parents cb499ca + 388c438 commit 13aff57
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sal/system_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
CRYPT_URL = None
DEPLOYED_ON_CHECKIN = False
INACTIVE_UNDEPLOYED = 0
SEARCH_FACTS = []
SEARCH_CONDITIONS = []

TEMPLATES = [
{
Expand Down
2 changes: 1 addition & 1 deletion sal/version.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>version</key>
<string>3.2.8.1028</string>
<string>3.2.8.1024</string>
</dict>
</plist>
14 changes: 14 additions & 0 deletions search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ def quick_search(machines, query_string):

queries = [Q(**{"%s__icontains" % f.name: query_string}) for f in fields]

for f in settings.SEARCH_FACTS:
query = {
'facts__fact_name': f,
'facts__fact_data__icontains': query_string
}
queries.append(Q(**query))

for f in settings.SEARCH_CONDITIONS:
query = {
'conditions__condition_name': f,
'conditions__condition_data__icontains': query_string
}
queries.append(Q(**query))

qs = Q()
for query in queries:
qs = qs | query
Expand Down

0 comments on commit 13aff57

Please sign in to comment.