Skip to content

Commit

Permalink
Fix error message in strict int filter
Browse files Browse the repository at this point in the history
The filter displayed name of filter as the database filter, not what
user specified.

JIRA: PDC-999
  • Loading branch information
lubomir committed Sep 15, 2015
1 parent 6d2fee9 commit 77c9053
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pdc/apps/common/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,22 @@ class MultiIntFilter(MultiValueFilter):
"""
MultiValueFilter that reports error when input is not a number.
"""
@property
def display_name(self):
"""
Get name of the filter used by the user.
"""
for name, filter in self.parent.filters.iteritems():
if filter == self:
return name
raise ValueError('Filter not defined in parent')

@value_is_not_empty
def filter(self, qs, value):
# This can't actually call to parent method, as double invocation of
# @value_is_not_empty would cause the filter with empty value to be
# ignored.
value = [convert_str_to_int(val, name=self.name) for val in value]
value = [convert_str_to_int(val, name=self.display_name) for val in value]
qs = qs.filter(**{self.name + '__in': value})
if self.distinct:
qs = qs.distinct()
Expand Down

0 comments on commit 77c9053

Please sign in to comment.