Skip to content

Commit

Permalink
Merge pull request #33 from miki725/default-filter-strict
Browse files Browse the repository at this point in the history
Default filter strict
  • Loading branch information
miki725 committed May 18, 2017
2 parents 6b8e2a0 + e3d8c53 commit 8b031cf
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: python

python:
- "3.5"
- "3.6"
- "2.7"
- "pypy"

env:
- "$DJANGO='django<1.9'"
- "$DJANGO='django<2'"

sudo: false

Expand Down
8 changes: 7 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
History
-------

0.3.1 (2017-05-18)
~~~~~~~~~~~~~~~~~~

* Fixed bug where default filters were used in root filtersets.
As a result additional querystring parameters were validation which
broke other functionality such as pagination.

0.3.0 (2017-01-26)
~~~~~~~~~~~~~~~~~~

Expand All @@ -17,7 +24,6 @@ History
See `#20 <https://github.com/miki725/django-url-filter/issues/20>`_.
* Releasing with `wheels <http://pythonwheels.com/>`_.


0.2.0 (2015-09-12)
~~~~~~~~~~~~~~~~~~

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ clean-test:
clean-test-all: clean-test
rm -rf .tox/

importanize:
importanize --ci

lint:
flake8 .
python --version | grep "Python 3" && make importanize || true

test:
py.test -sv --cov=url_filter --cov-report=term-missing --doctest-modules tests/ url_filter/
Expand Down
3 changes: 2 additions & 1 deletion tests/filtersets/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class BarFilterSet(FilterSet):
thing = Filter(form_field=forms.IntegerField(min_value=0, max_value=15))

class FooFilterSet(FilterSet):
field = Filter(form_field=forms.CharField())
field = Filter(form_field=forms.CharField(), is_default=True)
bar = BarFilterSet()

def _test(data, expected, **kwargs):
Expand All @@ -188,6 +188,7 @@ def _test(data, expected, **kwargs):
FilterSpec(['bar', 'id'], 'isnull', True, False),
])
_test('bar__gt=foo', [])
_test('page=1', [], strict_mode=StrictMode.fail)

def test_filter_one_to_one(self, one_to_one):
class PlaceFilterSet(FilterSet):
Expand Down
12 changes: 5 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tox]
envlist =
{py27,py34,py35,pypy}-django{18,19}
{py27,py36,pypy}-django{18,11}
# 1.9 breaks pypy3 hence only testing with 18
{pypy3}-django{18}
# scandir fails to install in pypy3 so skippint for now
# {pypy3}-django{18}

[testenv]
basepython =
py27: python2.7
py34: python3.4
py35: python3.5
py36: python3.6
pypy: pypy
pypy3: pypy3
setenv =
Expand All @@ -18,10 +18,8 @@ commands =
pip freeze
make check
deps =
django16: django<1.7
django17: django<1.8
django18: django<1.9
django19: django<1.10
django11: django<2
whitelist_externals =
make

Expand Down
2 changes: 1 addition & 1 deletion url_filter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = 'Miroslav Shubernetskiy'
__email__ = 'miroslav@miki725.com'
__version__ = '0.3.0'
__version__ = '0.3.1'
4 changes: 3 additions & 1 deletion url_filter/filtersets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,12 @@ def get_spec(self, config):
value = LookupConfig(config.key, config.data)

if name not in self.filters:
if self.default_filter:
if self.default_filter and self is not self.root:
# if name is not found as a filter, there is a possibility
# it is a lookup made on the default filter of this filterset
# in which case we try to get that spec directly from the child
# however that is only allowed on nested filtersets
# since on root filterset filter must be specified
return self.default_filter.get_spec(config)
else:
raise SkipFilter
Expand Down

0 comments on commit 8b031cf

Please sign in to comment.