Skip to content

Commit

Permalink
Merge e479063 into 74371b7
Browse files Browse the repository at this point in the history
  • Loading branch information
xor-xor committed Sep 8, 2014
2 parents 74371b7 + e479063 commit 21109e7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ralph/ui/forms/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ class SearchForm(forms.Form):
'title': TooltipContent.empty_field,
}),
label="Venture or role")
# This search field cannot be named 'service', because 'Info' tab already
# has ajax field with the same id, and such collision results in unwanted
# data bindings between those two.
service_catalog = forms.CharField(required=False,
widget=forms.TextInput(attrs={
'class': 'span12',
'title': TooltipContent.empty_field,
}),
label="Service catalog")
device_environment = forms.CharField(required=False,
widget=forms.TextInput(attrs={
'class': 'span12',
'title': TooltipContent.empty_field,
}),
label="Device environment")
model = forms.CharField(required=False,
widget=forms.TextInput(attrs={
'class': 'span12',
Expand Down
18 changes: 18 additions & 0 deletions src/ralph/ui/views/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ def get_queryset(self):
self.query = self.query.filter(
remarks__icontains=data['remarks']
)
# This field cannot be named 'service' (see comment in SearchForm).
if data['service_catalog']:
if data['service_catalog'] == empty_field:
self.query = self.query.filter(service='')
else:
self.query = self.query.filter(
service__name__icontains=data['service_catalog']
)

if data['device_environment']:
if data['device_environment'] == empty_field:
self.query = self.query.filter(device_environment='')
else:
self.query = self.query.filter(
device_environment__name__icontains=data[
'device_environment'
]
)
if data['model']:
if data['model'] == empty_field:
self.query = self.query.filter(
Expand Down

0 comments on commit 21109e7

Please sign in to comment.