diff -Nru django-filter-0.11.0/CHANGES.rst django-filter-0.13.0/CHANGES.rst --- django-filter-0.11.0/CHANGES.rst 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/CHANGES.rst 2016-03-11 19:42:49.000000000 +0000 @@ -1,3 +1,43 @@ +Version 0.13.0 (2016-03-11) +--------------------------- + +* Add support for filtering by CSV #363 + +* Add DateTimeFromToRangeFilter #376 + +* Add Chinese translation #359 + +* Lots of fixes. + + +Version 0.12.0 (2016-01-07) +--------------------------- + +* Raised minimum Django version to 1.8.x + +* FEATURE: Add support for custom ORM lookup types #221 + +* FEATURE: Add JavaScript friendly BooleanWidget #270 + +* FIXED: (More) Compatability with Django 1.8 and Django 1.9+ + +* BREAKING CHANGE: custom filter names are now also be used for ordering #230 + + If you use ordering on a field you defined as custom filter with custom + name, you should now use the filter name as ordering key as well. + + Eg. For a filter like : + + class F(FilterSet): + account = CharFilter(name='username') + class Meta: + model = User + fields = ['account', 'status'] + order_by = True + + Before, ordering was like `?o=username`. Since 0.12.0 it's `o=account`. + + Version 0.11.0 (2015-08-14) --------------------------- diff -Nru django-filter-0.11.0/debian/changelog django-filter-0.13.0/debian/changelog --- django-filter-0.11.0/debian/changelog 2015-10-26 02:04:44.000000000 +0000 +++ django-filter-0.13.0/debian/changelog 2016-04-06 02:39:30.000000000 +0000 @@ -1,3 +1,13 @@ +django-filter (0.13.0-1) unstable; urgency=medium + + [ Ondřej Nový ] + * Fixed homepage (https) + + [ Brian May ] + * New upstream version. + + -- Brian May Wed, 06 Apr 2016 12:39:17 +1000 + django-filter (0.11.0-2) unstable; urgency=medium * Run tests for all Python 3.* diff -Nru django-filter-0.11.0/debian/control django-filter-0.13.0/debian/control --- django-filter-0.11.0/debian/control 2015-10-09 23:01:22.000000000 +0000 +++ django-filter-0.13.0/debian/control 2016-04-06 02:39:05.000000000 +0000 @@ -10,8 +10,8 @@ Build-Depends-Indep: libjs-jquery, python-sphinx (>= 1.0.7+dfsg-1~) Standards-Version: 3.9.6 X-Python-Version: >= 2.6 -Homepage: http://github.com/alex/django-filter -Vcs-Git: git://anonscm.debian.org/python-modules/packages/django-filter.git +Homepage: https://github.com/alex/django-filter +Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/django-filter.git Vcs-Browser: https://anonscm.debian.org/cgit/python-modules/packages/django-filter.git Package: python-django-filters diff -Nru django-filter-0.11.0/debian/.git-dpm django-filter-0.13.0/debian/.git-dpm --- django-filter-0.11.0/debian/.git-dpm 2015-10-09 23:01:22.000000000 +0000 +++ django-filter-0.13.0/debian/.git-dpm 2016-04-06 02:39:06.000000000 +0000 @@ -1,11 +1,11 @@ # see git-dpm(1) from git-dpm package -d2e50dcc8fd58b62ccca7adcaf3d90fe0e88d40b -d2e50dcc8fd58b62ccca7adcaf3d90fe0e88d40b -9b2333ed6baed573a0058790b9678bb619d21bda -9b2333ed6baed573a0058790b9678bb619d21bda -django-filter_0.11.0.orig.tar.gz -8a6c61511d5da419dd4eba0ba0e4ec8912a3b926 -203673 +99b05f1fbdb81b1494e5cfa89576e493450b30b1 +99b05f1fbdb81b1494e5cfa89576e493450b30b1 +99b05f1fbdb81b1494e5cfa89576e493450b30b1 +99b05f1fbdb81b1494e5cfa89576e493450b30b1 +django-filter_0.13.0.orig.tar.gz +7dd049fd0e2d82e329bdc73bb30f1e306edc7b5c +94527 debianTag="debian/%e%v" patchedTag="patched/%e%v" upstreamTag="upstream/%e%u" diff -Nru django-filter-0.11.0/debian/patches/fix_tests.patch django-filter-0.13.0/debian/patches/fix_tests.patch --- django-filter-0.11.0/debian/patches/fix_tests.patch 2015-10-09 23:01:22.000000000 +0000 +++ django-filter-0.13.0/debian/patches/fix_tests.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -From d2e50dcc8fd58b62ccca7adcaf3d90fe0e88d40b Mon Sep 17 00:00:00 2001 -From: SVN-Git Migration -Date: Thu, 8 Oct 2015 08:52:07 -0700 -Subject: fix_tests - -Patch-Name: fix_tests.patch ---- - django_filters/filters.py | 2 +- - tests/test_filters.py | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/django_filters/filters.py b/django_filters/filters.py -index 9295fe5..1042de0 100644 ---- a/django_filters/filters.py -+++ b/django_filters/filters.py -@@ -84,9 +84,9 @@ class Filter(object): - lookup = self.lookup_type - if value in ([], (), {}, None, ''): - return qs -- qs = self.get_method(qs)(**{'%s__%s' % (self.name, lookup): value}) - if self.distinct: - qs = qs.distinct() -+ qs = self.get_method(qs)(**{'%s__%s' % (self.name, lookup): value}) - return qs - - -diff --git a/tests/test_filters.py b/tests/test_filters.py -index 68bbd37..a631b6d 100644 ---- a/tests/test_filters.py -+++ b/tests/test_filters.py -@@ -189,7 +189,7 @@ class FilterTests(TestCase): - qs = mock.Mock(spec=['filter', 'distinct']) - f = Filter(name='somefield', distinct=True) - f.filter(qs, 'value') -- result = qs.distinct.assert_called_once() -+ result = qs.distinct.assert_called_once_with() - self.assertNotEqual(qs, result) - - diff -Nru django-filter-0.11.0/debian/patches/series django-filter-0.13.0/debian/patches/series --- django-filter-0.11.0/debian/patches/series 2015-10-09 23:01:22.000000000 +0000 +++ django-filter-0.13.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -fix_tests.patch diff -Nru django-filter-0.11.0/django_filter.egg-info/PKG-INFO django-filter-0.13.0/django_filter.egg-info/PKG-INFO --- django-filter-0.11.0/django_filter.egg-info/PKG-INFO 2015-08-14 10:21:52.000000000 +0000 +++ django-filter-0.13.0/django_filter.egg-info/PKG-INFO 2016-03-11 19:43:42.000000000 +0000 @@ -1,10 +1,10 @@ Metadata-Version: 1.1 Name: django-filter -Version: 0.11.0 +Version: 0.13.0 Summary: Django-filter is a reusable Django application for allowing users to filter querysets dynamically. -Home-page: http://github.com/alex/django-filter/tree/master -Author: Alex Gaynor -Author-email: alex.gaynor@gmail.com +Home-page: http://github.com/carltongibson/django-filter/tree/master +Author: Carlton Gibson +Author-email: carlton.gibson@noumenal.es License: BSD Description: Django Filter ============= @@ -14,14 +14,14 @@ Full documentation on `read the docs`_. - .. image:: https://secure.travis-ci.org/alex/django-filter.png?branch=master - :target: http://travis-ci.org/alex/django-filter + .. image:: https://travis-ci.org/carltongibson/django-filter.svg?branch=master + :target: https://travis-ci.org/carltongibson/django-filter Requirements ------------ - * Python 2.6+ - * Django 1.4.5+ + * Python 2.7, 3.2, 3.3, 3.4, 3.5 + * Django 1.8, 1.9 Installation ------------ @@ -32,7 +32,7 @@ Or clone the repo and add to your PYTHONPATH:: - git clone git@github.com:alex/django-filter.git + git clone git@github.com:carltongibson/django-filter.git Usage ----- @@ -54,11 +54,11 @@ def product_list(request): filter = ProductFilter(request.GET, queryset=Product.objects.all()) - return render_to_response('my_app/template.html', {'filter': filter}) + return render(request, 'my_app/template.html', {'filter': filter}) Django-filters additionally supports specifying FilterSet fields using a dictionary to specify filters with lookup types:: - + import django_filters class ProductFilter(django_filters.FilterSet): @@ -87,10 +87,10 @@ Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 Classifier: Framework :: Django diff -Nru django-filter-0.11.0/django_filter.egg-info/SOURCES.txt django-filter-0.13.0/django_filter.egg-info/SOURCES.txt --- django-filter-0.11.0/django_filter.egg-info/SOURCES.txt 2015-08-14 10:22:02.000000000 +0000 +++ django-filter-0.13.0/django_filter.egg-info/SOURCES.txt 2016-03-11 19:44:01.000000000 +0000 @@ -13,16 +13,23 @@ django_filter.egg-info/not-zip-safe django_filter.egg-info/top_level.txt django_filters/__init__.py +django_filters/compat.py django_filters/fields.py django_filters/filters.py django_filters/filterset.py django_filters/models.py +django_filters/utils.py django_filters/views.py django_filters/widgets.py django_filters/locale/de/LC_MESSAGES/django.mo django_filters/locale/de/LC_MESSAGES/django.po +django_filters/locale/es_AR/LC_MESSAGES/django.mo +django_filters/locale/es_AR/LC_MESSAGES/django.po django_filters/locale/fr/LC_MESSAGES/django.mo django_filters/locale/fr/LC_MESSAGES/django.po +django_filters/locale/pl/LC_MESSAGES/django.mo +django_filters/locale/pl/LC_MESSAGES/django.po +django_filters/locale/zh_CN/LC_MESSAGES/django.po docs/.DS_Store docs/Makefile docs/conf.py @@ -31,55 +38,11 @@ docs/make.bat docs/tests.txt docs/usage.txt -docs/_build/.DS_Store -docs/_build/doctrees/environment.pickle -docs/_build/doctrees/index.doctree -docs/_build/doctrees/install.doctree -docs/_build/doctrees/tests.doctree -docs/_build/doctrees/usage.doctree -docs/_build/doctrees/ref/filters.doctree -docs/_build/doctrees/ref/widgets.doctree -docs/_build/html/.buildinfo -docs/_build/html/genindex.html -docs/_build/html/index.html -docs/_build/html/install.html -docs/_build/html/objects.inv -docs/_build/html/search.html -docs/_build/html/searchindex.js -docs/_build/html/tests.html -docs/_build/html/usage.html -docs/_build/html/_sources/index.txt -docs/_build/html/_sources/install.txt -docs/_build/html/_sources/tests.txt -docs/_build/html/_sources/usage.txt -docs/_build/html/_sources/ref/filters.txt -docs/_build/html/_sources/ref/widgets.txt -docs/_build/html/_static/ajax-loader.gif -docs/_build/html/_static/basic.css -docs/_build/html/_static/comment-bright.png -docs/_build/html/_static/comment-close.png -docs/_build/html/_static/comment.png -docs/_build/html/_static/default.css -docs/_build/html/_static/doctools.js -docs/_build/html/_static/down-pressed.png -docs/_build/html/_static/down.png -docs/_build/html/_static/file.png -docs/_build/html/_static/jquery.js -docs/_build/html/_static/minus.png -docs/_build/html/_static/plus.png -docs/_build/html/_static/pygments.css -docs/_build/html/_static/searchtools.js -docs/_build/html/_static/sidebar.js -docs/_build/html/_static/underscore.js -docs/_build/html/_static/up-pressed.png -docs/_build/html/_static/up.png -docs/_build/html/_static/websupport.js -docs/_build/html/ref/filters.html -docs/_build/html/ref/widgets.html docs/ref/fields.txt docs/ref/filters.txt +docs/ref/filterset.txt +docs/ref/settings.txt docs/ref/widgets.txt -requirements/docs.txt requirements/maintainer.txt requirements/test.txt requirements/travis-ci.txt @@ -87,6 +50,7 @@ tests/__init__.pyc tests/models.py tests/models.pyc +tests/settings.py tests/test_fields.py tests/test_fields.pyc tests/test_filtering.py @@ -97,6 +61,7 @@ tests/test_filterset.pyc tests/test_forms.py tests/test_forms.pyc +tests/test_utils.py tests/test_views.py tests/test_views.pyc tests/test_widgets.py diff -Nru django-filter-0.11.0/django_filters/compat.py django-filter-0.13.0/django_filters/compat.py --- django-filter-0.11.0/django_filters/compat.py 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/django_filters/compat.py 2016-03-11 19:42:49.000000000 +0000 @@ -0,0 +1,17 @@ + +import django + + +def remote_field(field): + """ + https://docs.djangoproject.com/en/1.9/releases/1.9/#field-rel-changes + """ + if django.VERSION >= (1, 9): + return field.remote_field + return field.rel + + +def remote_model(field): + if django.VERSION >= (1, 9): + return remote_field(field).model + return remote_field(field).to diff -Nru django-filter-0.11.0/django_filters/fields.py django-filter-0.13.0/django_filters/fields.py --- django-filter-0.11.0/django_filters/fields.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/django_filters/fields.py 2016-03-11 19:42:49.000000000 +0000 @@ -7,13 +7,11 @@ from django import forms from django.utils.dateparse import parse_datetime -# TODO: Remove this once Django 1.4 is EOL. -try: - from django.utils.encoding import force_str -except ImportError: - force_str = None +from django.utils.encoding import force_str +from django.utils.translation import ugettext_lazy as _ -from .widgets import RangeWidget, LookupTypeWidget +from .utils import handle_timezone +from .widgets import RangeWidget, LookupTypeWidget, CSVWidget class RangeField(forms.MultiValueField): @@ -44,13 +42,24 @@ if data_list: start_date, stop_date = data_list if start_date: - start_date = datetime.combine(start_date, time.min) + start_date = handle_timezone( + datetime.combine(start_date, time.min)) if stop_date: - stop_date = datetime.combine(stop_date, time.max) + stop_date = handle_timezone( + datetime.combine(stop_date, time.max)) return slice(start_date, stop_date) return None +class DateTimeRangeField(RangeField): + + def __init__(self, *args, **kwargs): + fields = ( + forms.DateTimeField(), + forms.DateTimeField()) + super(DateTimeRangeField, self).__init__(fields, *args, **kwargs) + + class TimeRangeField(RangeField): def __init__(self, *args, **kwargs): @@ -60,7 +69,14 @@ super(TimeRangeField, self).__init__(fields, *args, **kwargs) -Lookup = namedtuple('Lookup', ('value', 'lookup_type')) +class Lookup(namedtuple('Lookup', ('value', 'lookup_type'))): + # python nature is test __len__ on tuple types for boolean check + def __len__(self): + if not self.value: + return 0 + return 2 + + class LookupTypeField(forms.MultiValueField): def __init__(self, field, lookup_choices, *args, **kwargs): fields = ( @@ -75,7 +91,7 @@ super(LookupTypeField, self).__init__(fields, *args, **kwargs) def compress(self, data_list): - if len(data_list)==2: + if len(data_list) == 2: return Lookup(value=data_list[0], lookup_type=data_list[1] or 'exact') return Lookup(value=None, lookup_type='exact') @@ -93,13 +109,45 @@ input_formats = [ISO_8601] def strptime(self, value, format): - # TODO: Remove this once Django 1.4 is EOL. - if force_str is not None: - value = force_str(value) + value = force_str(value) if format == self.ISO_8601: parsed = parse_datetime(value) if parsed is None: # Continue with other formats if doesn't match raise ValueError - return parsed + return handle_timezone(parsed) return super(IsoDateTimeField, self).strptime(value, format) + + +class BaseCSVField(forms.Field): + """ + Base field for validating CSV types. Value validation is performed by + secondary base classes. + + ex:: + class IntegerCSVField(BaseCSVField, filters.IntegerField): + pass + + """ + widget = CSVWidget + + def clean(self, value): + if value is None: + return None + return [super(BaseCSVField, self).clean(v) for v in value] + + +class BaseRangeField(BaseCSVField): + default_error_messages = { + 'invalid_values': _('Range query expects two values.') + } + + def clean(self, value): + value = super(BaseRangeField, self).clean(value) + + if value is not None and len(value) != 2: + raise forms.ValidationError( + self.error_messages['invalid_values'], + code='invalid_values') + + return value diff -Nru django-filter-0.11.0/django_filters/filterset.py django-filter-0.13.0/django_filters/filterset.py --- django-filter-0.11.0/django_filters/filterset.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/django_filters/filterset.py 2016-03-11 19:42:49.000000000 +0000 @@ -1,54 +1,30 @@ from __future__ import absolute_import from __future__ import unicode_literals -import types import copy +import re +from collections import OrderedDict from django import forms from django.forms.forms import NON_FIELD_ERRORS from django.core.validators import EMPTY_VALUES from django.db import models -from django.db.models.fields import FieldDoesNotExist +from django.db.models.constants import LOOKUP_SEP +from django.db.models.fields.related import ForeignObjectRel from django.utils import six from django.utils.text import capfirst from django.utils.translation import ugettext as _ -from sys import version_info -try: - from django.db.models.constants import LOOKUP_SEP -except ImportError: # pragma: nocover - # Django < 1.5 fallback - from django.db.models.sql.constants import LOOKUP_SEP # noqa - -try: - from collections import OrderedDict -except ImportError: # pragma: nocover - # Django < 1.5 fallback - from django.utils.datastructures import SortedDict as OrderedDict # noqa - -try: - from django.db.models.related import RelatedObject as ForeignObjectRel -except ImportError: # pragma: nocover - # Django >= 1.8 replaces RelatedObject with ForeignObjectRel - from django.db.models.fields.related import ForeignObjectRel - - -from .filters import (Filter, CharFilter, BooleanFilter, - ChoiceFilter, DateFilter, DateTimeFilter, TimeFilter, ModelChoiceFilter, - ModelMultipleChoiceFilter, NumberFilter) +from .compat import remote_field, remote_model +from .filters import (Filter, CharFilter, BooleanFilter, BaseInFilter, BaseRangeFilter, + ChoiceFilter, DateFilter, DateTimeFilter, TimeFilter, ModelChoiceFilter, + ModelMultipleChoiceFilter, NumberFilter, UUIDFilter) +from .utils import try_dbfield, get_model_field, resolve_field ORDER_BY_FIELD = 'o' -# There is a bug with deepcopy in 2.6, patch if we are running python < 2.7 -# http://bugs.python.org/issue1515 -if version_info < (2, 7, 0): - def _deepcopy_method(x, memo): - return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class) - copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method - - class STRICTNESS(object): """ Values of False & True chosen for backward compatability reasons. @@ -81,38 +57,13 @@ return OrderedDict(filters) -def get_model_field(model, f): - parts = f.split(LOOKUP_SEP) - opts = model._meta - for name in parts[:-1]: - try: - rel = opts.get_field_by_name(name)[0] - except FieldDoesNotExist: - return None - if isinstance(rel, ForeignObjectRel): - if hasattr(rel, "related_model"): - # django >= 1.8 (ForeignObjectRel) - opts = rel.related_model._meta - else: - # django < 1.8 (RelatedObject) - opts = rel.opts - else: - model = rel.rel.to - opts = model._meta - try: - rel, model, direct, m2m = opts.get_field_by_name(parts[-1]) - except FieldDoesNotExist: - return None - return rel - - def filters_for_model(model, fields=None, exclude=None, filter_for_field=None, filter_for_reverse_field=None): field_dict = OrderedDict() opts = model._meta if fields is None: fields = [f.name for f in sorted(opts.fields + opts.many_to_many) - if not isinstance(f, models.AutoField)] + if not isinstance(f, models.AutoField)] # Loop through the list of fields. for f in fields: # Skip the field if excluded. @@ -130,14 +81,17 @@ # If fields is a dictionary, it must contain lists. elif isinstance(fields, dict): # Create a filter for each lookup type. - for lookup_type in fields[f]: - filter_ = filter_for_field(field, f, lookup_type) + for lookup_expr in fields[f]: + filter_ = filter_for_field(field, f, lookup_expr) if filter_: - filter_name = f + filter_name = LOOKUP_SEP.join([f, lookup_expr]) + # Don't add "exact" to filter names - if lookup_type != 'exact': - filter_name = f + LOOKUP_SEP + lookup_type + _exact = LOOKUP_SEP + 'exact' + if filter_name.endswith(_exact): + filter_name = filter_name[:-len(_exact)] + field_dict[filter_name] = filter_ # If fields is a list, it contains strings. else: @@ -149,18 +103,18 @@ def get_full_clean_override(together): def full_clean(form): - + def add_error(message): try: form.add_error(None, message) except AttributeError: form._errors[NON_FIELD_ERRORS] = message - + def all_valid(fieldset): cleaned_data = form.cleaned_data count = len([i for i in fieldset if cleaned_data.get(i)]) return 0 < count < len(fieldset) - + super(form.__class__, form).full_clean() message = 'Following fields must be together: %s' if isinstance(together[0], (list, tuple)): @@ -181,7 +135,7 @@ self.order_by = getattr(options, 'order_by', False) self.form = getattr(options, 'form', forms.Form) - + self.together = getattr(options, 'together', None) @@ -209,9 +163,10 @@ else: filters = declared_filters - if None in filters.values(): + not_defined = next((k for k, v in filters.items() if v is None), False) + if not_defined: raise TypeError("Meta.fields contains a field that isn't defined " - "on this FilterSet") + "on this FilterSet: {}".format(not_defined)) new_class.declared_filters = declared_filters new_class.base_filters = filters @@ -243,24 +198,24 @@ models.OneToOneField: { 'filter_class': ModelChoiceFilter, 'extra': lambda f: { - 'queryset': f.rel.to._default_manager.complex_filter( - f.rel.limit_choices_to), - 'to_field_name': f.rel.field_name, + 'queryset': remote_model(f)._default_manager.complex_filter( + remote_field(f).limit_choices_to), + 'to_field_name': remote_field(f).field_name, } }, models.ForeignKey: { 'filter_class': ModelChoiceFilter, 'extra': lambda f: { - 'queryset': f.rel.to._default_manager.complex_filter( - f.rel.limit_choices_to), - 'to_field_name': f.rel.field_name + 'queryset': remote_model(f)._default_manager.complex_filter( + remote_field(f).limit_choices_to), + 'to_field_name': remote_field(f).field_name } }, models.ManyToManyField: { 'filter_class': ModelMultipleChoiceFilter, 'extra': lambda f: { - 'queryset': f.rel.to._default_manager.complex_filter( - f.rel.limit_choices_to), + 'queryset': remote_model(f)._default_manager.complex_filter( + remote_field(f).limit_choices_to), } }, models.DecimalField: { @@ -296,12 +251,15 @@ models.URLField: { 'filter_class': CharFilter, }, - models.IPAddressField: { + models.GenericIPAddressField: { 'filter_class': CharFilter, }, models.CommaSeparatedIntegerField: { 'filter_class': CharFilter, }, + models.UUIDField: { + 'filter_class': UUIDFilter, + }, } @@ -335,7 +293,7 @@ yield obj def __len__(self): - return len(self.qs) + return self.qs.count() def __getitem__(self, key): return self.qs[key] @@ -383,7 +341,9 @@ except forms.ValidationError: pass - if ordered_value in EMPTY_VALUES and self.strict: + # With a None-queryset, ordering must be enforced (#84). + if (ordered_value in EMPTY_VALUES and + self.strict == STRICTNESS.RETURN_NO_RESULTS): ordered_value = self.form.fields[self.order_by_field].choices[0][0] if ordered_value: @@ -420,16 +380,21 @@ # e.g. (('field', 'Display name'), ...) choices = [(f[0], f[1]) for f in self._meta.order_by] else: - choices = [(f, _('%s (descending)' % capfirst(f[1:])) if f[0] == '-' else capfirst(f)) - for f in self._meta.order_by] + choices = [] + for f in self._meta.order_by: + if f[0] == '-': + label = _('%s (descending)' % capfirst(f[1:])) + else: + label = capfirst(f) + choices.append((f, label)) else: # add asc and desc field names # use the filter's label if provided choices = [] for f, fltr in self.filters.items(): choices.extend([ - (fltr.name or f, fltr.label or capfirst(f)), - ("-%s" % (fltr.name or f), _('%s (descending)' % (fltr.label or capfirst(f)))) + (f, fltr.label or capfirst(f)), + ("-%s" % (f), _('%s (descending)' % (fltr.label or capfirst(f)))) ]) return forms.ChoiceField(label=_("Ordering"), required=False, choices=choices) @@ -441,44 +406,36 @@ return self._ordering_field def get_order_by(self, order_choice): + re_ordering_field = re.compile(r'(?P\-?)(?P.*)') + m = re.match(re_ordering_field, order_choice) + inverted = m.group('inverse') + filter_api_name = m.group('field') + + _filter = self.filters.get(filter_api_name, None) + + if _filter and filter_api_name != _filter.name: + return [inverted + _filter.name] return [order_choice] @classmethod - def filter_for_field(cls, f, name, lookup_type='exact'): - filter_for_field = dict(FILTER_FOR_DBFIELD_DEFAULTS) - filter_for_field.update(cls.filter_overrides) + def filter_for_field(cls, f, name, lookup_expr='exact'): + f, lookup_type = resolve_field(f, lookup_expr) default = { 'name': name, 'label': capfirst(f.verbose_name), - 'lookup_type': lookup_type + 'lookup_expr': lookup_expr } - if f.choices: - default['choices'] = f.choices - return ChoiceFilter(**default) + filter_class, params = cls.filter_for_lookup(f, lookup_type) + default.update(params) - data = filter_for_field.get(f.__class__) - if data is None: - # could be a derived field, inspect parents - for class_ in f.__class__.mro(): - # skip if class_ is models.Field or object - # 1st item in mro() is original class - if class_ in (f.__class__, models.Field, object): - continue - data = filter_for_field.get(class_) - if data: - break - if data is None: - return - filter_class = data.get('filter_class') - default.update(data.get('extra', lambda f: {})(f)) if filter_class is not None: return filter_class(**default) @classmethod def filter_for_reverse_field(cls, f, name): - rel = f.field.rel + rel = remote_field(f.field) queryset = f.field.model._default_manager.all() default = { 'name': name, @@ -490,6 +447,76 @@ else: return ModelChoiceFilter(**default) + @classmethod + def filter_for_lookup(cls, f, lookup_type): + DEFAULTS = dict(FILTER_FOR_DBFIELD_DEFAULTS) + DEFAULTS.update(cls.filter_overrides) + + data = try_dbfield(DEFAULTS.get, f.__class__) or {} + filter_class = data.get('filter_class') + params = data.get('extra', lambda f: {})(f) + + # if there is no filter class, exit early + if not filter_class: + return None, {} + + # perform lookup specific checks + if lookup_type == 'isnull': + data = try_dbfield(DEFAULTS.get, models.BooleanField) + + filter_class = data.get('filter_class') + params = data.get('extra', lambda f: {})(f) + return filter_class, params + + if lookup_type == 'in': + class ConcreteInFilter(BaseInFilter, filter_class): + pass + ConcreteInFilter.__name__ = cls._csv_filter_class_name( + filter_class, lookup_type + ) + + return ConcreteInFilter, params + + if lookup_type == 'range': + class ConcreteRangeFilter(BaseRangeFilter, filter_class): + pass + ConcreteRangeFilter.__name__ = cls._csv_filter_class_name( + filter_class, lookup_type + ) + + return ConcreteRangeFilter, params + + # Default behavior + if f.choices: + return ChoiceFilter, {'choices': f.choices} + + return filter_class, params + + @classmethod + def _csv_filter_class_name(cls, filter_class, lookup_type): + """ + Generate a suitable class name for a concrete filter class. This is not + completely reliable, as not all filter class names are of the format + Filter. + + ex:: + + FilterSet._csv_filter_class_name(DateTimeFilter, 'in') + + returns 'DateTimeInFilter' + + """ + # DateTimeFilter => DateTime + type_name = filter_class.__name__ + if type_name.endswith('Filter'): + type_name = type_name[:-6] + + # in => In + lookup_name = lookup_type.capitalize() + + # DateTimeInFilter + return str('%s%sFilter' % (type_name, lookup_name)) + class FilterSet(six.with_metaclass(FilterSetMetaclass, BaseFilterSet)): pass diff -Nru django-filter-0.11.0/django_filters/filters.py django-filter-0.13.0/django_filters/filters.py --- django-filter-0.11.0/django_filters/filters.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/django_filters/filters.py 2016-03-11 19:42:49.000000000 +0000 @@ -1,18 +1,22 @@ from __future__ import absolute_import from __future__ import unicode_literals +import warnings from datetime import timedelta - from django import forms from django.db.models import Q from django.db.models.sql.constants import QUERY_TERMS +from django.db.models.constants import LOOKUP_SEP +from django.conf import settings from django.utils import six from django.utils.timezone import now from django.utils.translation import ugettext_lazy as _ from .fields import ( - RangeField, LookupTypeField, Lookup, DateRangeField, TimeRangeField, IsoDateTimeField) + Lookup, LookupTypeField, BaseCSVField, BaseRangeField, RangeField, + DateRangeField, DateTimeRangeField, TimeRangeField, IsoDateTimeField +) __all__ = [ @@ -20,25 +24,34 @@ 'TypedChoiceFilter', 'MultipleChoiceFilter', 'DateFilter', 'DateTimeFilter', 'IsoDateTimeFilter', 'TimeFilter', 'ModelChoiceFilter', 'ModelMultipleChoiceFilter', 'NumberFilter', 'NumericRangeFilter', 'RangeFilter', - 'DateRangeFilter', 'DateFromToRangeFilter', 'TimeRangeFilter', - 'AllValuesFilter', 'MethodFilter' + 'DateRangeFilter', 'DateFromToRangeFilter', 'DateTimeFromToRangeFilter', + 'TimeRangeFilter', 'AllValuesFilter', 'MethodFilter' ] LOOKUP_TYPES = sorted(QUERY_TERMS) +def _lookup_type_warning(): + warnings.warn('lookup_type is deprecated. Use lookup_expr instead.', DeprecationWarning, stacklevel=3) + + class Filter(object): creation_counter = 0 field_class = forms.Field def __init__(self, name=None, label=None, widget=None, action=None, - lookup_type='exact', required=False, distinct=False, exclude=False, **kwargs): + lookup_expr='exact', required=False, distinct=False, exclude=False, **kwargs): self.name = name self.label = label if action: self.filter = action - self.lookup_type = lookup_type + + self.lookup_expr = lookup_expr + if 'lookup_type' in kwargs: + _lookup_type_warning() + self.lookup_expr = kwargs.pop('lookup_type') + self.widget = widget self.required = required self.extra = kwargs @@ -54,26 +67,58 @@ """ return qs.exclude if self.exclude else qs.filter + def lookup_type(): + def fget(self): + _lookup_type_warning() + return self.lookup_expr + + def fset(self, value): + _lookup_type_warning() + self.lookup_expr = value + + return locals() + lookup_type = property(**lookup_type()) + @property def field(self): if not hasattr(self, '_field'): help_text = self.extra.pop('help_text', None) if help_text is None: - help_text = _('This is an exclusion filter') if self.exclude else _('Filter') - if (self.lookup_type is None or - isinstance(self.lookup_type, (list, tuple))): - if self.lookup_type is None: - lookup = [(x, x) for x in LOOKUP_TYPES] + if self.exclude and getattr(settings, "FILTERS_HELP_TEXT_EXCLUDE", True): + help_text = _('This is an exclusion filter') + elif not self.exclude and getattr(settings, "FILTERS_HELP_TEXT_FILTER", True): + help_text = _('Filter') else: - lookup = [ - (x, x) for x in LOOKUP_TYPES if x in self.lookup_type] + help_text = '' + + if (self.lookup_expr is None or + isinstance(self.lookup_expr, (list, tuple))): + + lookup = [] + + for x in LOOKUP_TYPES: + if isinstance(x, (list, tuple)) and len(x) == 2: + choice = (x[0], x[1]) + else: + choice = (x, x) + + if self.lookup_expr is None: + lookup.append(choice) + else: + if isinstance(x, (list, tuple)) and len(x) == 2: + if x[0] in self.lookup_expr: + lookup.append(choice) + else: + if x in self.lookup_expr: + lookup.append(choice) + self._field = LookupTypeField(self.field_class( required=self.required, widget=self.widget, **self.extra), lookup, required=self.required, label=self.label, help_text=help_text) else: self._field = self.field_class(required=self.required, - label=self.label, widget=self.widget, - help_text=help_text, **self.extra) + label=self.label, widget=self.widget, + help_text=help_text, **self.extra) return self._field def filter(self, qs, value): @@ -81,12 +126,12 @@ lookup = six.text_type(value.lookup_type) value = value.value else: - lookup = self.lookup_type + lookup = self.lookup_expr if value in ([], (), {}, None, ''): return qs - qs = self.get_method(qs)(**{'%s__%s' % (self.name, lookup): value}) if self.distinct: qs = qs.distinct() + qs = self.get_method(qs)(**{'%s__%s' % (self.name, lookup): value}) return qs @@ -97,11 +142,6 @@ class BooleanFilter(Filter): field_class = forms.NullBooleanField - def filter(self, qs, value): - if value is not None: - return self.get_method(qs)(**{self.name: value}) - return qs - class ChoiceFilter(Filter): field_class = forms.ChoiceField @@ -111,6 +151,10 @@ field_class = forms.TypedChoiceField +class UUIDFilter(Filter): + field_class = forms.UUIDField + + class MultipleChoiceFilter(Filter): """ This filter preforms OR(by default) or AND(using conjoined=True) query @@ -156,7 +200,7 @@ return False def filter(self, qs, value): - value = value or () # Make sure we have an iterable + value = value or () # Make sure we have an iterable if self.is_noop(qs, value): return qs @@ -185,6 +229,7 @@ class DateTimeFilter(Filter): field_class = forms.DateTimeField + class IsoDateTimeFilter(DateTimeFilter): """ Uses IsoDateTimeField to support filtering on ISO 8601 formated datetimes. @@ -197,6 +242,7 @@ """ field_class = IsoDateTimeField + class TimeFilter(Filter): field_class = forms.TimeField @@ -219,7 +265,7 @@ def filter(self, qs, value): if value: if value.start is not None and value.stop is not None: - lookup = '%s__%s' % (self.name, self.lookup_type) + lookup = '%s__%s' % (self.name, self.lookup_expr) return self.get_method(qs)(**{lookup: (value.start, value.stop)}) else: if value.start is not None: @@ -234,19 +280,19 @@ def filter(self, qs, value): if value: - if value.start is not None and value.stop is not None: - lookup = '%s__range' % self.name - return self.get_method(qs)(**{lookup: (value.start, value.stop)}) - else: - - if value.start is not None: - qs = self.get_method(qs)(**{'%s__gte'%self.name:value.start}) - if value.stop is not None: - qs = self.get_method(qs)(**{'%s__lte'%self.name:value.stop}) + if value.start is not None and value.stop is not None: + lookup = '%s__range' % self.name + return self.get_method(qs)(**{lookup: (value.start, value.stop)}) + else: + if value.start is not None: + qs = self.get_method(qs)(**{'%s__gte' % self.name: value.start}) + if value.stop is not None: + qs = self.get_method(qs)(**{'%s__lte' % self.name: value.stop}) return qs -_truncate = lambda dt: dt.replace(hour=0, minute=0, second=0) +def _truncate(dt): + return dt.replace(hour=0, minute=0, second=0) class DateRangeFilter(ChoiceFilter): @@ -285,13 +331,20 @@ value = int(value) except (ValueError, TypeError): value = '' - return self.options[value][1](qs, self.name) + qs = self.options[value][1](qs, self.name) + if self.distinct: + qs = qs.distinct() + return qs class DateFromToRangeFilter(RangeFilter): field_class = DateRangeField +class DateTimeFromToRangeFilter(RangeFilter): + field_class = DateTimeRangeField + + class TimeRangeFilter(RangeFilter): field_class = TimeRangeField @@ -305,6 +358,65 @@ return super(AllValuesFilter, self).field +class BaseCSVFilter(Filter): + """ + Base class for CSV type filters, such as IN and RANGE. + """ + base_field_class = BaseCSVField + + def __init__(self, *args, **kwargs): + super(BaseCSVFilter, self).__init__(*args, **kwargs) + + class ConcreteCSVField(self.base_field_class, self.field_class): + pass + ConcreteCSVField.__name__ = self._field_class_name( + self.field_class, self.lookup_expr + ) + + self.field_class = ConcreteCSVField + + @classmethod + def _field_class_name(cls, field_class, lookup_expr): + """ + Generate a suitable class name for the concrete field class. This is not + completely reliable, as not all field class names are of the format + Field. + + ex:: + + BaseCSVFilter._field_class_name(DateTimeField, 'year__in') + + returns 'DateTimeYearInField' + + """ + # DateTimeField => DateTime + type_name = field_class.__name__ + if type_name.endswith('Field'): + type_name = type_name[:-5] + + # year__in => YearIn + parts = lookup_expr.split(LOOKUP_SEP) + expression_name = ''.join(p.capitalize() for p in parts) + + # DateTimeYearInField + return str('%s%sField' % (type_name, expression_name)) + + +class BaseInFilter(BaseCSVFilter): + + def __init__(self, *args, **kwargs): + kwargs.setdefault('lookup_expr', 'in') + super(BaseInFilter, self).__init__(*args, **kwargs) + + +class BaseRangeFilter(BaseCSVFilter): + base_field_class = BaseRangeField + + def __init__(self, *args, **kwargs): + kwargs.setdefault('lookup_expr', 'range') + super(BaseRangeFilter, self).__init__(*args, **kwargs) + + class MethodFilter(Filter): """ This filter will allow you to run a method that exists on the filterset class diff -Nru django-filter-0.11.0/django_filters/__init__.py django-filter-0.13.0/django_filters/__init__.py --- django-filter-0.11.0/django_filters/__init__.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/django_filters/__init__.py 2016-03-11 19:42:49.000000000 +0000 @@ -3,7 +3,7 @@ from .filterset import FilterSet from .filters import * -__version__ = '0.11.0' +__version__ = '0.13.0' def parse_version(version): Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/django_filters/locale/es_AR/LC_MESSAGES/django.mo and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/django_filters/locale/es_AR/LC_MESSAGES/django.mo differ diff -Nru django-filter-0.11.0/django_filters/locale/es_AR/LC_MESSAGES/django.po django-filter-0.13.0/django_filters/locale/es_AR/LC_MESSAGES/django.po --- django-filter-0.11.0/django_filters/locale/es_AR/LC_MESSAGES/django.po 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/django_filters/locale/es_AR/LC_MESSAGES/django.po 2016-01-07 19:51:07.000000000 +0000 @@ -0,0 +1,47 @@ +# Django Filter translation. +# Copyright (C) 2013 +# This file is distributed under the same license as the django_filter package. +# Gonzalo Bustos, 2015. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-05 19:24+0200\n" +"PO-Revision-Date: 2015-10-11 20:53-0300\n" +"Last-Translator: Gonzalo Bustos\n" +"Language-Team: Spanish (Argentina)\n" +"Language: es_AR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 1.6.10\n" + +#: filters.py:51 +msgid "This is an exclusion filter" +msgstr "Este es un filtro de exclusión" + +#: filters.py:158 +msgid "Any date" +msgstr "Cualquier fecha" + +#: filters.py:159 +msgid "Today" +msgstr "Hoy" + +#: filters.py:164 +msgid "Past 7 days" +msgstr "Últimos 7 días" + +#: filters.py:168 +msgid "This month" +msgstr "Este mes" + +#: filters.py:172 +msgid "This year" +msgstr "Este año" + +#: widgets.py:63 +msgid "All" +msgstr "Todos" Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/django_filters/locale/pl/LC_MESSAGES/django.mo and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/django_filters/locale/pl/LC_MESSAGES/django.mo differ diff -Nru django-filter-0.11.0/django_filters/locale/pl/LC_MESSAGES/django.po django-filter-0.13.0/django_filters/locale/pl/LC_MESSAGES/django.po --- django-filter-0.11.0/django_filters/locale/pl/LC_MESSAGES/django.po 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/django_filters/locale/pl/LC_MESSAGES/django.po 2016-01-07 19:51:07.000000000 +0000 @@ -0,0 +1,65 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: django_filters 0.0.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-25 01:24+0200\n" +"PO-Revision-Date: 2015-07-25 01:27+0100\n" +"Last-Translator: Adam Dobrawy \n" +"Language-Team: Adam Dobrawy \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" +"X-Generator: Poedit 1.5.4\n" +"Language: pl_PL\n" + +#: filters.py:56 +msgid "This is an exclusion filter" +msgstr "Jest to filtr wykluczający" + +#: filters.py:56 +msgid "Filter" +msgstr "Filter" + +#: filters.py:226 +msgid "Any date" +msgstr "Dowolna data" + +#: filters.py:227 +msgid "Today" +msgstr "Dziś" + +#: filters.py:232 +msgid "Past 7 days" +msgstr "Ostatnie 7 dni" + +#: filters.py:236 +msgid "This month" +msgstr "Ten miesiąc" + +#: filters.py:240 +msgid "This year" +msgstr "Ten rok" + +#: filters.py:243 +msgid "Yesterday" +msgstr "Wczoraj" + +#: filterset.py:423 filterset.py:432 +#, python-format +msgid "%s (descending)" +msgstr "%s (malejąco)" + +#: filterset.py:434 +msgid "Ordering" +msgstr "Sortowanie" + +#: widgets.py:63 +msgid "All" +msgstr "Wszystko" diff -Nru django-filter-0.11.0/django_filters/locale/zh_CN/LC_MESSAGES/django.po django-filter-0.13.0/django_filters/locale/zh_CN/LC_MESSAGES/django.po --- django-filter-0.11.0/django_filters/locale/zh_CN/LC_MESSAGES/django.po 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/django_filters/locale/zh_CN/LC_MESSAGES/django.po 2016-03-11 19:42:49.000000000 +0000 @@ -0,0 +1,64 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Kane Blueriver , 2016. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-30 17:39+0800\n" +"PO-Revision-Date: 2016-01-30 17:50+0800\n" +"Last-Translator: Kane Blueriver \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#: filters.py:62 +msgid "This is an exclusion filter" +msgstr "未启用该过滤器" + +#: filters.py:62 +msgid "Filter" +msgstr "过滤器" + +#: filters.py:264 +msgid "Any date" +msgstr "任何时刻" + +#: filters.py:265 +msgid "Today" +msgstr "今日" + +#: filters.py:270 +msgid "Past 7 days" +msgstr "过去 7 日" + +#: filters.py:274 +msgid "This month" +msgstr "本月" + +#: filters.py:278 +msgid "This year" +msgstr "今年" + +#: filters.py:281 +msgid "Yesterday" +msgstr "昨日" + +#: filterset.py:398 filterset.py:409 +#, python-format +msgid "%s (descending)" +msgstr "%s(降序)" + +#: filterset.py:411 +msgid "Ordering" +msgstr "排序" + +#: widgets.py:60 +msgid "All" +msgstr "全部" diff -Nru django-filter-0.11.0/django_filters/utils.py django-filter-0.13.0/django_filters/utils.py --- django-filter-0.11.0/django_filters/utils.py 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/django_filters/utils.py 2016-03-11 19:42:49.000000000 +0000 @@ -0,0 +1,104 @@ +from django.conf import settings +from django.db import models +from django.db.models.constants import LOOKUP_SEP +from django.db.models.expressions import Expression +from django.db.models.fields import FieldDoesNotExist +from django.db.models.fields.related import ForeignObjectRel +from django.utils import timezone + +from .compat import remote_model + + +def try_dbfield(fn, field_class): + """ + Try ``fn`` with the DB ``field_class`` by walking its + MRO until a result is found. + + ex:: + _try_dbfield(field_dict.get, models.CharField) + + """ + # walk the mro, as field_class could be a derived model field. + for cls in field_class.mro(): + # skip if cls is models.Field + if cls is models.Field: + continue + + data = fn(cls) + if data: + return data + + +def get_model_field(model, field_name): + """ + Get a ``model`` field, traversing relationships + in the ``field_name``. + + ex:: + + f = get_model_field(Book, 'author__first_name') + + """ + parts = field_name.split(LOOKUP_SEP) + opts = model._meta + + # walk relationships + for name in parts[:-1]: + try: + rel = opts.get_field(name) + except FieldDoesNotExist: + return None + if isinstance(rel, ForeignObjectRel): + opts = rel.related_model._meta + else: + opts = remote_model(rel)._meta + + try: + return opts.get_field(parts[-1]) + except FieldDoesNotExist: + return None + + +def resolve_field(model_field, lookup_expr): + """ + Resolves a ``lookup_expr`` into its final output field, given + the initial ``model_field``. The lookup expression should only contain + transforms and lookups, not intermediary model field parts. + + Note: + This method is based on django.db.models.sql.query.Query.build_lookup + + For more info on the lookup API: + https://docs.djangoproject.com/en/1.9/ref/models/lookups/ + + """ + query = model_field.model._default_manager.all().query + lhs = Expression(model_field) + lookups = lookup_expr.split(LOOKUP_SEP) + + assert len(lookups) > 0 + + while lookups: + name = lookups[0] + # If there is just one part left, try first get_lookup() so + # that if the lhs supports both transform and lookup for the + # name, then lookup will be picked. + if len(lookups) == 1: + final_lookup = lhs.get_lookup(name) + if not final_lookup: + # We didn't find a lookup. We are going to interpret + # the name as transform, and do an Exact lookup against + # it. + lhs = query.try_transform(lhs, name, lookups) + final_lookup = lhs.get_lookup('exact') + return lhs.output_field, final_lookup.lookup_name + lhs = query.try_transform(lhs, name, lookups) + lookups = lookups[1:] + + +def handle_timezone(value): + if settings.USE_TZ and timezone.is_naive(value): + return timezone.make_aware(value, timezone.get_default_timezone()) + elif not settings.USE_TZ and timezone.is_aware(value): + return timezone.make_naive(value, timezone.UTC()) + return value diff -Nru django-filter-0.11.0/django_filters/widgets.py django-filter-0.13.0/django_filters/widgets.py --- django-filter-0.11.0/django_filters/widgets.py 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/django_filters/widgets.py 2016-03-11 19:42:49.000000000 +0000 @@ -1,6 +1,7 @@ from __future__ import absolute_import from __future__ import unicode_literals +from collections import Iterable from itertools import chain try: from urllib.parse import urlencode @@ -10,11 +11,9 @@ from django import forms from django.db.models.fields import BLANK_CHOICE_DASH from django.forms.widgets import flatatt -try: - from django.utils.encoding import force_text -except: # pragma: nocover - from django.utils.encoding import force_unicode as force_text # noqa +from django.utils.encoding import force_text from django.utils.safestring import mark_safe +from django.utils.six import string_types from django.utils.translation import ugettext as _ @@ -80,7 +79,7 @@ class RangeWidget(forms.MultiWidget): def __init__(self, attrs=None): - widgets = (forms.TextInput(attrs=attrs), forms.TextInput(attrs=attrs)) + widgets = (forms.TextInput, forms.TextInput) super(RangeWidget, self).__init__(widgets, attrs) def decompress(self, value): @@ -97,3 +96,60 @@ if value is None: return [None, None] return value + + +class BooleanWidget(forms.Select): + """Convert true/false values into the internal Python True/False. + This can be used for AJAX queries that pass true/false from JavaScript's + internal types through. + """ + def __init__(self, attrs=None): + choices = (('', _('Unknown')), + ('true', _('Yes')), + ('false', _('No'))) + super(BooleanWidget, self).__init__(attrs, choices) + + def render(self, name, value, attrs=None): + try: + value = { + True: 'true', + False: 'false', + '1': 'true', + '0': 'false' + }[value] + except KeyError: + value = '' + return super(BooleanWidget, self).render(name, value, attrs) + + def value_from_datadict(self, data, files, name): + value = data.get(name, None) + if isinstance(value, string_types): + value = value.lower() + + return { + '1': True, + '0': False, + 'true': True, + 'false': False, + True: True, + False: False, + }.get(value, None) + + +class CSVWidget(forms.TextInput): + def _isiterable(self, value): + return isinstance(value, Iterable) and not isinstance(value, string_types) + + def value_from_datadict(self, data, files, name): + value = super(CSVWidget, self).value_from_datadict(data, files, name) + + if value is not None: + return value.split(',') + return None + + def render(self, name, value, attrs=None): + if self._isiterable(value): + value = [force_text(self._format_value(v)) for v in value] + value = ','.join(list(value)) + + return super(CSVWidget, self).render(name, value, attrs) Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/doctrees/environment.pickle and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/doctrees/environment.pickle differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/doctrees/index.doctree and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/doctrees/index.doctree differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/doctrees/install.doctree and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/doctrees/install.doctree differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/doctrees/ref/filters.doctree and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/doctrees/ref/filters.doctree differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/doctrees/ref/widgets.doctree and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/doctrees/ref/widgets.doctree differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/doctrees/tests.doctree and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/doctrees/tests.doctree differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/doctrees/usage.doctree and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/doctrees/usage.doctree differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/.DS_Store and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/.DS_Store differ diff -Nru django-filter-0.11.0/docs/_build/html/.buildinfo django-filter-0.13.0/docs/_build/html/.buildinfo --- django-filter-0.11.0/docs/_build/html/.buildinfo 2014-11-28 11:13:33.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/.buildinfo 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -# Sphinx build info version 1 -# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 882f14951f7370aee1cee594c96e3783 -tags: 645f666f9bcd5a90fca523b33c5a78b7 diff -Nru django-filter-0.11.0/docs/_build/html/genindex.html django-filter-0.13.0/docs/_build/html/genindex.html --- django-filter-0.11.0/docs/_build/html/genindex.html 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/genindex.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ - - - - - - - - - Index — django-filter 0.9.0 documentation - - - - - - - - - - - - - -
-
-
-
- - -

Index

- -
- -
- - -
-
-
-
-
- - - - - -
-
-
-
- - - - \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/index.html django-filter-0.13.0/docs/_build/html/index.html --- django-filter-0.11.0/docs/_build/html/index.html 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/index.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ - - - - - - - - django-filter — django-filter 0.9.0 documentation - - - - - - - - - - - - - - -
-
-
-
- -
-

django-filter

-

Django-filter is a generic, reusable application to alleviate writing some of -the more mundane bits of view code. Specifically, it allows users to filter -down a queryset based on a model’s fields, displaying the form to let them -do this.

-

Contents:

- -
- - -
-
-
-
-
-

Next topic

-

Installing django-filter

-

This Page

- - - -
-
-
-
- - - - \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/install.html django-filter-0.13.0/docs/_build/html/install.html --- django-filter-0.11.0/docs/_build/html/install.html 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/install.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ - - - - - - - - Installing django-filter — django-filter 0.9.0 documentation - - - - - - - - - - - - - - - -
-
-
-
- -
-

Installing django-filter

-

To install, simply place the django_filters directory somewhere on your -PYTHONPATH, and then add 'django_filters' to your INSTALLED_APPS.

-
- - -
-
-
-
-
-

Previous topic

-

django-filter

-

Next topic

-

Using django-filter

-

This Page

- - - -
-
-
-
- - - - \ No newline at end of file Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/objects.inv and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/objects.inv differ diff -Nru django-filter-0.11.0/docs/_build/html/ref/filters.html django-filter-0.13.0/docs/_build/html/ref/filters.html --- django-filter-0.11.0/docs/_build/html/ref/filters.html 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/ref/filters.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,319 +0,0 @@ - - - - - - - - Filter Reference — django-filter 0.9.0 documentation - - - - - - - - - - - - - - - -
-
-
-
- -
-

Filter Reference

-

This is a reference document with a list of the filters and their arguments.

-
-

Filters

-
-

CharFilter

-

This filter does simple character matches, used with CharField and -TextField by default.

-
-
-

BooleanFilter

-

This filter matches a boolean, either True or False, used with -BooleanField and NullBooleanField by default.

-
-
-

ChoiceFilter

-

This filter matches an item of any type by choices, used with any field that -has choices.

-
-
-

TypedChoiceFilter

-

The same as ChoiceFilter with the added possibility to convert value to -match against. This could be done by using coerce parameter. -An example use-case is limiting boolean choices to match against so only -some predefined strings could be used as input of a boolean filter:

-
import django_filters
-from distutils.util import strtobool
-
-BOOLEAN_CHOICES = (('false', 'False'), ('true', 'True'),)
-
-class YourFilterSet(django_filters.FilterSet):
-    ...
-    flag = django_filters.TypedChoiceFilter(choices=BOOLEAN_CHOICES,
-                                            coerce=strtobool)
-
-
-
-
-

MultipleChoiceFilter

-

The same as ChoiceFilter except the user can select multiple items and it -selects the OR of all the choices.

-

Advanced Use: Depending on your application logic, when all or no choices are -selected, filtering may be a noop. In this case you may wish to avoid the -filtering overhead, particularly of the distinct call.

-

Set always_filter to False after instantiation to enable the default is_noop -test.

-

Override is_noop if you require a different test for your application.

-
-
-

DateFilter

-

Matches on a date. Used with DateField by default.

-
-
-

DateTimeFilter

-

Matches on a date and time. Used with DateTimeField by default.

-
-
-

TimeFilter

-

Matches on a time. Used with TimeField by default.

-
-
-

ModelChoiceFilter

-

Similar to a ChoiceFilter except it works with related models, used for -ForeignKey by default.

-
-
-

ModelMultipleChoiceFilter

-

Similar to a MultipleChoiceFilter except it works with related models, used -for ManyToManyField by default.

-
-
-

NumberFilter

-

Filters based on a numerical value, used with IntegerField, FloatField, -and DecimalField by default.

-
-
-

RangeFilter

-

Filters where a value is between two numerical values, or greater than a minimum or less than a maximum where only one limit value is provided.

-
class F(FilterSet):
-    """Filter for Books by Price"""
-    price = RangeFilter()
-
-    class Meta:
-        model = Book
-        fields = ['price']
-
-qs = Book.objects.all().order_by('title')
-
-# Range: Books between 5€ and 15€
-f = F({'price_0': '5', 'price_1': '15'}, queryset=qs)
-
-# Min-Only: Books costing more the 11€
-f = F({'price_0': '11'}, queryset=qs)
-
-# Max-Only: Books costing less than 19€
-f = F({'price_1': '19'}, queryset=qs)
-
-
-
-
-

DateRangeFilter

-

Filter similar to the admin changelist date one, it has a number of common -selections for working with date fields.

-
-
-

AllValuesFilter

-

This is a ChoiceFilter whose choices are the current values in the -database. So if in the DB for the given field you have values of 5, 7, and 9 -each of those is present as an option. This is similar to the default behavior -of the admin.

-
-
-

MethodFilter

-

This is a Filter that will allow you to run a method that exists on the filter set that -this filter is a property of. Set the action to a string that will map to a method on the -filter set class.

-
-
-
-

Core Arguments

-
-

name

-

The name of the field this filter is supposed to filter on, if this is not -provided it automatically becomes the filter’s name on the FilterSet.

-
-
-

label

-

The label as it will apear in the HTML, analogous to a form field’s label -argument.

-
-
-

widget

-

The django.form Widget class which will represent the Filter. In addition -to the widgets that are included with Django that you can use there are -additional ones that django-filter provides which may be useful:

-
-
    -
  • django_filters.widgets.LinkWidget – this displays the options in a -mannner similar to the way the Django Admin does, as a series of links. -The link for the selected option will have class="selected".
  • -
-
-
-
-

action

-

An optional callable that tells the filter how to handle the queryset. It -recieves a QuerySet and the value to filter on and should return a -Queryset that is filtered appropriately.

-
-
-

lookup_type

-

The type of lookup that should be performed using the [Django ORM](https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups “Django’s ORM Lookups”). -All the normal options are allowed, and should be provided as a string. You can also -provide either None or a list or a tuple. If None is provided, -then the user can select the lookup type from all the ones available in the Django -ORM. If a list or tuple is provided, then the user can select from those -options.

-
-
-

distinct

-

A boolean value that specifies whether the Filter will use distinct on the -queryset. This option can be used to eliminate duplicate results when using filters that span related models. Defaults to False.

-
-
-

exclude

-

A boolean value that specifies whether the Filter should use filter or exclude on the queryset. -Defaults to False.

-
-
-

**kwargs

-

Any extra keyword arguments will be provided to the accompanying form Field. -This can be used to provide arguments like choices or queryset.

-
-
-
- - -
-
-
-
-
-

Table Of Contents

- - -

Previous topic

-

Using django-filter

-

Next topic

-

Widget Reference

-

This Page

- - - -
-
-
-
- - - - \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/ref/widgets.html django-filter-0.13.0/docs/_build/html/ref/widgets.html --- django-filter-0.11.0/docs/_build/html/ref/widgets.html 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/ref/widgets.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ - - - - - - - - Widget Reference — django-filter 0.9.0 documentation - - - - - - - - - - - - - - - -
-
-
-
- -
-

Widget Reference

-

This is a reference document with a list of the provided widgets and their -arguments.

-
-

LinkWidget

-

This widget renders each option as a link, instead of an actual <input>. It has -one method that you can overide for additional customizability. -option_string() should return a string with 3 Python keyword argument -placeholders:

-
    -
  1. attrs: This is a string with all the attributes that will be on the -final <a> tag.
  2. -
  3. query_string: This is the query string for use in the href -option on the <a> elemeent.
  4. -
  5. label: This is the text to be displayed to the user.
  6. -
-
-
- - -
-
-
-
-
-

Table Of Contents

- - -

Previous topic

-

Filter Reference

-

Next topic

-

Running the django-filter tests

-

This Page

- - - -
-
-
-
- - - - \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/search.html django-filter-0.13.0/docs/_build/html/search.html --- django-filter-0.11.0/docs/_build/html/search.html 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/search.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ - - - - - - - - Search — django-filter 0.9.0 documentation - - - - - - - - - - - - - - - - - - - -
-
-
-
- -

Search

-
- -

- Please activate JavaScript to enable the search - functionality. -

-
-

- From here you can search these documents. Enter your search - words into the box below and click "search". Note that the search - function will automatically search for all of the words. Pages - containing fewer words won't appear in the result list. -

-
- - - -
- -
- -
- -
-
-
-
-
-
-
-
-
- - - - \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/searchindex.js django-filter-0.13.0/docs/_build/html/searchindex.js --- django-filter-0.11.0/docs/_build/html/searchindex.js 2014-11-28 11:13:33.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/searchindex.js 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -Search.setIndex({envversion:42,terms:{all:[5,2,1,3],code:[5,0,1],forget:5,queri:[5,3],signific:5,follow:1,whose:2,depend:[],those:[5,2],filterset_class:5,query_str:3,get_order_bi:5,sourc:1,string:[5,2,3],fals:[5,2],price__gt:5,util:2,veri:5,exact:5,ref:2,overid:3,list:[5,2,3],last_nam:5,iter:5,item:[5,2],listview:5,cost:2,pass:5,what:5,access:5,"new":[5,1],method:[],widget:[],abov:5,gener:[],never:5,here:5,let:[5,0],path:5,becom:2,valu:[5,2],price_1:2,price_0:2,convert:2,base:[5,0,2],overrid:[],extra:[5,2],app:5,deprec:5,"boolean":2,instal:[],txt:1,select:[5,2],from:[5,2],would:5,two:2,live:5,overhead:2,type:[5,2],tell:2,more:[2,0],sort:5,relat:[5,2],flag:2,obj:5,compani:5,hold:5,easiest:1,must:5,none:2,work:[5,2],dev:2,tag:3,can:[5,2,1,3],empty_label:5,def:5,filter_class:5,control:5,loosen:5,indic:5,manytomanyfield:2,minimum:2,want:5,multipl:[5,2],first_nam:5,mundan:0,object_list:5,write:[5,0],how:2,place:4,simpl:[5,2],updat:5,map:2,product:5,max:2,clone:1,after:2,charfield:[5,2],mai:[5,2],strtobool:2,github:1,virutalenv:1,apear:2,"switch":1,allow:[5,0,2],enter:5,callabl:2,lambda:5,over:5,becaus:5,still:5,paramet:[5,2],render:3,complex:5,linkwidget:[],therefor:5,them:[5,0],lastli:5,"return":[5,2,3],greater:2,thei:5,handl:2,initi:5,number:[5,2],filter_overrid:5,instead:3,now:5,choic:2,somewher:4,achiev:5,average_r:5,each:[2,3],found:5,mean:5,runtest:1,expect:5,our:5,out:1,variabl:5,content:[5,0],userfilt:5,modelform:5,urlpattern:5,advanc:2,differ:2,orm:[5,2],dictionari:5,reusabl:0,could:2,datetimefield:2,pagin:5,isn:5,as_p:5,onto:5,first:5,rang:2,directli:5,option_str:3,placehold:3,date:2,legaci:5,done:2,timefield:2,installed_app:4,predefin:2,given:2,script:1,wrapper:1,max_length:5,"final":3,store:5,inner:5,option:[],relationship:5,always_filt:2,specifi:[5,2],accompani:2,textfield:[5,2],than:[5,2],kind:5,django_filt:[5,2,4],keyword:[5,2,3],provid:[5,2,3],charact:2,seri:2,sai:5,runner:1,changelist:2,queryset:[5,0,2],ani:[5,2],object_filt:5,have:[5,2,1],tabl:5,need:5,min:2,self:5,note:5,also:[5,2],exampl:[5,2],take:5,which:[5,2],thi:[5,0,3,2],integerfield:2,normal:[5,2],usernam:5,price:[5,2],object:[5,2],why:5,allevi:0,doc:2,request:5,doe:2,declar:5,databas:2,show:5,text:[5,3],syntax:5,particularli:2,current:2,onli:2,coerc:2,locat:1,activ:1,should:[2,3],manufactur:5,suppos:2,decimalfield:[5,2],boolean_choic:2,requir:[2,1],enabl:2,is_noop:2,whether:[5,2],common:[5,2],contain:5,where:[2,1],view:[],set:[],elimin:2,maximum:2,see:5,result:[5,2],arg:5,price__lt:5,analog:2,wonder:5,pattern:5,between:2,my_app:5,"import":[5,2],modeladmin:5,attribut:[5,3],extend:5,numer:2,addit:[5,2,3],last:5,admin:[5,2],similar:[5,2],against:2,context:5,logic:2,com:[2,1],simpli:4,instanti:2,foobar:5,mannner:2,assum:1,duplic:[5,2],reciev:2,quit:5,addition:5,empti:5,search:5,floatfield:2,present:2,"case":[5,2],properti:2,behavior:[5,2],as_view:5,endblock:5,customiz:3,itself:5,href:3,myapp:5,"__init__":5,perform:2,same:[5,2],python:[1,3],"_filter":5,html:[5,2],document:[2,3],filterset:[],http:[2,1],order_valu:5,effect:5,render_to_respons:5,nullbooleanfield:2,user:[5,0,3,2],distutil:2,appropri:2,yourfilterset:2,elem:3,without:5,command:1,endfor:5,model:[],datefield:[5,2],just:5,less:[5,2],display_nam:5,except:2,icontain:5,add:[5,4],input:[5,2,3],match:2,bin:1,applic:[2,0],format:5,field_nam:5,alex:1,bit:0,like:[5,2],specif:0,arbitrari:5,manufacturer__countri:5,order_by_field:5,api:5,either:[5,2],page:5,some:[2,0],djangoproject:2,avoid:2,subclass:5,noop:2,foo:5,refer:[],run:[],release_d:5,usag:5,although:5,"super":5,actual:3,manag:5,filterview:5,product_list:5,block:5,pythonpath:4,within:1,automat:2,down:[5,0],contrib:5,bool:5,your:[5,2,4],git:1,span:2,wai:[5,2,1],submit:5,custom:[],avail:[2,1],start:5,includ:[5,2],call:[5,2],"function":5,form:[],tupl:[5,2],link:[2,3],"true":[5,2],attr:3,possibl:[5,2],"default":[5,2],wish:2,displai:[5,0,3,2],limit:2,foreignkei:[5,2],booleanfield:2,creat:[5,1],doesn:5,repres:2,exist:2,pip:1,check:1,probabl:5,titl:2,when:[5,2],invalid:5,field:[5,0,2],book:2,lookup:[5,2],test:[],you:[5,2,1,3],star:5,sequenc:5,"class":[5,2],directori:[1,4],descript:5,productfilt:5,ignor:5,time:2},objtypes:{},objnames:{},filenames:["index","tests","ref/filters","ref/widgets","install","usage"],titles:["django-filter","Running the django-filter tests","Filter Reference","Widget Reference","Installing django-filter","Using django-filter"],objects:{},titleterms:{overrid:5,set:1,methodfilt:2,allvaluesfilt:2,datetimefilt:2,argument:2,templat:5,datefilt:2,kwarg:2,conf:5,rangefilt:2,instal:[1,4],label:2,choicefilt:2,virtualenv:1,depend:1,lookup_typ:2,distinct:2,custom:5,strict:5,other:5,order_bi:5,modelchoicefilt:2,suit:1,test:1,django:[5,0,1,4],method:5,refer:[2,3],core:2,non:5,run:1,option:5,form:5,get:1,multiplechoicefilt:2,gener:5,copi:1,timefilt:2,get_ordering_field:5,typedchoicefilt:2,modelmultiplechoicefilt:2,linkwidget:3,name:2,url:5,widget:[2,3],exclud:2,filter:[5,0,1,2,4],meta:5,booleanfilt:2,numberfilt:2,charfilt:2,action:2,daterangefilt:2,model:5,filterset:5,order:5,view:5}}) \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/_sources/index.txt django-filter-0.13.0/docs/_build/html/_sources/index.txt --- django-filter-0.11.0/docs/_build/html/_sources/index.txt 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_sources/index.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -============= -django-filter -============= - -Django-filter is a generic, reusable application to alleviate writing some of -the more mundane bits of view code. Specifically, it allows users to filter -down a queryset based on a model's fields, displaying the form to let them -do this. - -Contents: - -.. toctree:: - :maxdepth: 1 - - install - usage - ref/filters - ref/widgets - tests diff -Nru django-filter-0.11.0/docs/_build/html/_sources/install.txt django-filter-0.13.0/docs/_build/html/_sources/install.txt --- django-filter-0.11.0/docs/_build/html/_sources/install.txt 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_sources/install.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -Installing django-filter ------------------------- - -To install, simply place the ``django_filters`` directory somewhere on your -``PYTHONPATH``, and then add ``'django_filters'`` to your ``INSTALLED_APPS``. diff -Nru django-filter-0.11.0/docs/_build/html/_sources/ref/filters.txt django-filter-0.13.0/docs/_build/html/_sources/ref/filters.txt --- django-filter-0.11.0/docs/_build/html/_sources/ref/filters.txt 2014-11-28 10:30:33.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_sources/ref/filters.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ -Filter Reference -================ - -This is a reference document with a list of the filters and their arguments. - -Filters -------- - -``CharFilter`` -~~~~~~~~~~~~~~ - -This filter does simple character matches, used with ``CharField`` and -``TextField`` by default. - -``BooleanFilter`` -~~~~~~~~~~~~~~~~~ - -This filter matches a boolean, either ``True`` or ``False``, used with -``BooleanField`` and ``NullBooleanField`` by default. - -``ChoiceFilter`` -~~~~~~~~~~~~~~~~ - -This filter matches an item of any type by choices, used with any field that -has ``choices``. - -``TypedChoiceFilter`` -~~~~~~~~~~~~~~~~~~~~~ - -The same as ``ChoiceFilter`` with the added possibility to convert value to -match against. This could be done by using `coerce` parameter. -An example use-case is limiting boolean choices to match against so only -some predefined strings could be used as input of a boolean filter:: - - import django_filters - from distutils.util import strtobool - - BOOLEAN_CHOICES = (('false', 'False'), ('true', 'True'),) - - class YourFilterSet(django_filters.FilterSet): - ... - flag = django_filters.TypedChoiceFilter(choices=BOOLEAN_CHOICES, - coerce=strtobool) - - -``MultipleChoiceFilter`` -~~~~~~~~~~~~~~~~~~~~~~~~ - -The same as ``ChoiceFilter`` except the user can select multiple items and it -selects the OR of all the choices. - -Advanced Use: Depending on your application logic, when all or no choices are -selected, filtering may be a noop. In this case you may wish to avoid the -filtering overhead, particularly of the `distinct` call. - -Set `always_filter` to False after instantiation to enable the default `is_noop` -test. - -Override `is_noop` if you require a different test for your application. - - -``DateFilter`` -~~~~~~~~~~~~~~ - -Matches on a date. Used with ``DateField`` by default. - -``DateTimeFilter`` -~~~~~~~~~~~~~~~~~~ - -Matches on a date and time. Used with ``DateTimeField`` by default. - -``TimeFilter`` -~~~~~~~~~~~~~~ - -Matches on a time. Used with ``TimeField`` by default. - -``ModelChoiceFilter`` -~~~~~~~~~~~~~~~~~~~~~ - -Similar to a ``ChoiceFilter`` except it works with related models, used for -``ForeignKey`` by default. - -``ModelMultipleChoiceFilter`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Similar to a ``MultipleChoiceFilter`` except it works with related models, used -for ``ManyToManyField`` by default. - -``NumberFilter`` -~~~~~~~~~~~~~~~~ - -Filters based on a numerical value, used with ``IntegerField``, ``FloatField``, -and ``DecimalField`` by default. - -``RangeFilter`` -~~~~~~~~~~~~~~~ - -Filters where a value is between two numerical values, or greater than a minimum or less than a maximum where only one limit value is provided. :: - - class F(FilterSet): - """Filter for Books by Price""" - price = RangeFilter() - - class Meta: - model = Book - fields = ['price'] - - qs = Book.objects.all().order_by('title') - - # Range: Books between 5€ and 15€ - f = F({'price_0': '5', 'price_1': '15'}, queryset=qs) - - # Min-Only: Books costing more the 11€ - f = F({'price_0': '11'}, queryset=qs) - - # Max-Only: Books costing less than 19€ - f = F({'price_1': '19'}, queryset=qs) - - -``DateRangeFilter`` -~~~~~~~~~~~~~~~~~~~ - -Filter similar to the admin changelist date one, it has a number of common -selections for working with date fields. - -``AllValuesFilter`` -~~~~~~~~~~~~~~~~~~~ - -This is a ``ChoiceFilter`` whose choices are the current values in the -database. So if in the DB for the given field you have values of 5, 7, and 9 -each of those is present as an option. This is similar to the default behavior -of the admin. - -``MethodFilter`` -~~~~~~~~~~~~~~~~~~~ - -This is a ``Filter`` that will allow you to run a method that exists on the filter set that -this filter is a property of. Set the `action` to a string that will map to a method on the -filter set class. - -Core Arguments --------------- - -``name`` -~~~~~~~~ - -The name of the field this filter is supposed to filter on, if this is not -provided it automatically becomes the filter's name on the ``FilterSet``. - -``label`` -~~~~~~~~~ - -The label as it will apear in the HTML, analogous to a form field's label -argument. - -``widget`` -~~~~~~~~~~ - -The django.form Widget class which will represent the ``Filter``. In addition -to the widgets that are included with Django that you can use there are -additional ones that django-filter provides which may be useful: - - * ``django_filters.widgets.LinkWidget`` -- this displays the options in a - mannner similar to the way the Django Admin does, as a series of links. - The link for the selected option will have ``class="selected"``. - -``action`` -~~~~~~~~~~ - -An optional callable that tells the filter how to handle the queryset. It -recieves a ``QuerySet`` and the value to filter on and should return a -``Queryset`` that is filtered appropriately. - -``lookup_type`` -~~~~~~~~~~~~~~~ - -The type of lookup that should be performed using the [Django ORM](https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups "Django's ORM Lookups"). -All the normal options are allowed, and should be provided as a string. You can also -provide either ``None`` or a ``list`` or a ``tuple``. If ``None`` is provided, -then the user can select the lookup type from all the ones available in the Django -ORM. If a ``list`` or ``tuple`` is provided, then the user can select from those -options. - -``distinct`` -~~~~~~~~~~~~ - -A boolean value that specifies whether the Filter will use distinct on the -queryset. This option can be used to eliminate duplicate results when using filters that span related models. Defaults to ``False``. - -``exclude`` -~~~~~~~~~~~ - -A boolean value that specifies whether the Filter should use ``filter`` or ``exclude`` on the queryset. -Defaults to ``False``. - - -``**kwargs`` -~~~~~~~~~~~~ - -Any extra keyword arguments will be provided to the accompanying form Field. -This can be used to provide arguments like ``choices`` or ``queryset``. diff -Nru django-filter-0.11.0/docs/_build/html/_sources/ref/widgets.txt django-filter-0.13.0/docs/_build/html/_sources/ref/widgets.txt --- django-filter-0.11.0/docs/_build/html/_sources/ref/widgets.txt 2014-09-25 13:15:14.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_sources/ref/widgets.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -Widget Reference -================ - -This is a reference document with a list of the provided widgets and their -arguments. - -``LinkWidget`` -~~~~~~~~~~~~~~ - -This widget renders each option as a link, instead of an actual . It has -one method that you can overide for additional customizability. -``option_string()`` should return a string with 3 Python keyword argument -placeholders:: - -1. ``attrs``: This is a string with all the attributes that will be on the - final ```` tag. -2. ``query_string``: This is the query string for use in the ``href`` - option on the ```` elemeent. -3. ``label``: This is the text to be displayed to the user. diff -Nru django-filter-0.11.0/docs/_build/html/_sources/tests.txt django-filter-0.13.0/docs/_build/html/_sources/tests.txt --- django-filter-0.11.0/docs/_build/html/_sources/tests.txt 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_sources/tests.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -Running the django-filter tests -=============================== - -The easiest way to run the django-filter tests is to check out the source -code into a virtualenv, where you can install the test dependencies. -django-filter uses a custom test runner to locate all of the tests, so a -wrapper script is available to set up and run the test suite. - -.. note:: - - The following assumes you have `virtualenv`__ and `git`__ installed. - -__ http://www.virtualenv.org -__ http://git-scm.com - -Set up a virtualenv for the test suite --------------------------------------- - -Run the following to create a new virtualenv to run the test suite in:: - - virtualenv django-filter-tests - cd django-filter-tests - . bin/activate - -Get a copy of django-filter ---------------------------- - -Get the django-filter source code using the following command:: - - git clone https://github.com/alex/django-filter.git - -Switch to the django-filter directory:: - - cd django-filter - -Install the test dependencies ------------------------------ - -Run the following to install the test dependencies within the -virutalenv:: - - pip install -r requirements/test.txt - -Run the django-filter tests:: - - python runtests.py - diff -Nru django-filter-0.11.0/docs/_build/html/_sources/usage.txt django-filter-0.13.0/docs/_build/html/_sources/usage.txt --- django-filter-0.11.0/docs/_build/html/_sources/usage.txt 2014-11-25 19:41:21.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_sources/usage.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,280 +0,0 @@ -Using django-filter -=================== - -Django-filter provides a simple way to filter down a queryset based on -parameters a user provides. Say we have a ``Product`` model and we want to let -our users filter which products they see on a list page. - -The model ---------- - -Let's start with our model:: - - from django.db import models - - class Product(models.Model): - name = models.CharField(max_length=255) - price = models.DecimalField() - description = models.TextField() - release_date = models.DateField() - manufacturer = models.ForeignKey(Manufacturer) - -The filter ----------- - -We have a number of fields and we want to let our users filter based on the -price or the release_date. We create a ``FilterSet`` for this:: - - import django_filters - - class ProductFilter(django_filters.FilterSet): - class Meta: - model = Product - fields = ['price', 'release_date'] - - -As you can see this uses a very similar API to Django's ``ModelForm``. Just -like with a ``ModelForm`` we can also override filters, or add new ones using a -declarative syntax:: - - import django_filters - - class ProductFilter(django_filters.FilterSet): - price = django_filters.NumberFilter(lookup_type='lt') - class Meta: - model = Product - fields = ['price', 'release_date'] - -Filters take a ``lookup_type`` argument which specifies what lookup type to -use with `Django's ORM`_. So here when a user entered a price it would show all -Products with a price less than that. - -.. _`Django's ORM`: https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups - -**It's quite common to forget to set lookup type for `CharField`s/`TextField`s -and wonder why search for "foo" doesn't return result for "foobar". It's because -default lookup type is exact text, but you probably want `icontains` lookup -field.** - -The FilterSet Meta class fields can additionally be set using a Dictionary to -specify multiple ``lookup_type`` filters without significant code duplication:: - - import django_filters - - class ProductFilter(django_filters.FilterSet): - class Meta: - model = Product - fields = {'price': ['lt', 'gt'], - 'release_date': ['exact'], - } - -The above would generate 'price__lt', 'price__gt' and 'release_date' filters. -The filter lookup type keyword 'exact' is the default and therefore never added -to a filter name. - -Items in the ``fields`` sequence in the ``Meta`` class may include -"relationship paths" using Django's ``__`` syntax to filter on fields on a -related model:: - - class ProductFilter(django_filters.FilterSet): - class Meta: - model = Product - fields = ['manufacturer__country'] - -Filters also take any arbitrary keyword arguments which get passed onto the -``django.forms.Field`` initializer. These extra keyword arguments get stored -in ``Filter.extra``, so it's possible to override the initializer of a -``FilterSet`` to add extra ones:: - - class ProductFilter(django_filters.FilterSet): - class Meta: - model = Product - fields = ['manufacturer'] - - def __init__(self, *args, **kwargs): - super(ProductFilter, self).__init__(*args, **kwargs) - self.filters['manufacturer'].extra.update( - {'empty_label': 'All Manufacturers'}) - -Like ``django.contrib.admin.ModelAdmin``, it is possible to override -default filters for all the models fields of the same kind using -``filter_overrides``:: - - class ProductFilter(django_filters.FilterSet): - filter_overrides = { - models.CharField: { - 'filter_class': django_filters.CharFilter, - 'extra': lambda f: { - 'lookup_type': 'icontains', - } - } - } - - class Meta: - model = Product - fields = ['name'] - - -The view --------- - -Now we need to write a view:: - - def product_list(request): - f = ProductFilter(request.GET, queryset=Product.objects.all()) - return render_to_response('my_app/template.html', {'filter': f}) - -If a queryset argument isn't provided then all the items in the default manager -of the model will be used. - -If you want to access the filtered objects in your views, for example if you -want to paginate them, you can do that. They are in f.qs - -The URL conf ------------- - -We need a URL pattern to call the view:: - - url(r'^list$', views.product_list) - -The template ------------- - -And lastly we need a template:: - - {% extends "base.html" %} - - {% block content %} -
- {{ filter.form.as_p }} - -
- {% for obj in filter %} - {{ obj.name }} - ${{ obj.price }}
- {% endfor %} - {% endblock %} - -And that's all there is to it! The ``form`` attribute contains a normal -Django form, and when we iterate over the ``FilterSet`` we get the objects in -the resulting queryset. - -Other Meta options ------------------- - -Ordering using ``order_by`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can allow the user to control ordering by providing the -``order_by`` argument in the Filter's Meta class. ``order_by`` can be either a -``list`` or ``tuple`` of field names, in which case those are the options, or -it can be a ``bool`` which, if True, indicates that all fields that -the user can filter on can also be sorted on. An example or ordering using a list:: - - import django_filters - - class ProductFilter(django_filters.FilterSet): - price = django_filters.NumberFilter(lookup_type='lt') - class Meta: - model = Product - fields = ['price', 'release_date'] - order_by = ['price'] - -If you want to control the display of items in ``order_by``, you can set it to -a list or tuple of 2-tuples in the format ``(field_name, display_name)``. -This lets you override the displayed names for your ordering fields:: - - order_by = ( - ('name', 'Company Name'), - ('average_rating', 'Stars'), - ) - -Note that the default query parameter name used for ordering is ``o``. You -can override this by setting an ``order_by_field`` attribute on the -``FilterSet`` class to the string value you would like to use. - -Custom Forms using ``form`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The inner ``Meta`` class also takes an optional ``form`` argument. This is a -form class from which ``FilterSet.form`` will subclass. This works similar to -the ``form`` option on a ``ModelAdmin.`` - -Non-Meta options ----------------- - -Note that these options do not go in the Meta class, they are specified directly -in your FilterSet class. - -``strict`` -~~~~~~~~~~ - -The ``strict`` option controls whether results are returned when an invalid -value is specified by the user for any filter field. By default, ``strict`` is -set to ``True`` meaning that an empty queryset is returned if any field contains -an invalid value. You can loosen this behavior by setting ``strict`` to -``False`` which will effectively ignore a filter field if its value is invalid. - -Overriding ``FilterSet`` methods --------------------------------- - -``get_ordering_field()`` -~~~~~~~~~~~~~~~~~~~~~~~~ - -If you want to use a custom widget, or in any other way override the ordering -field you can override the ``get_ordering_field()`` method on a ``FilterSet``. -This method just needs to return a Form Field. - -Ordering on multiple fields, or other complex orderings can be achieved by -overriding the ``Filterset.get_order_by()`` method. This is passed the selected -``order_by`` value, and is expected to return an iterable of values to pass to -``QuerySet.order_by``. For example, to sort a ``User`` table by last name, then -first name:: - - class UserFilter(django_filters.FilterSet): - class Meta: - order_by = ( - ('username', 'Username'), - ('last_name', 'Last Name') - ) - - def get_order_by(self, order_value): - if order_value == 'last_name': - return ['last_name', 'first_name'] - return super(UserFilter, self).get_order_by(order_value) - -Generic View ------------- - -In addition to the above usage there is also a class-based generic view -included in django-filter, which lives at ``django_filters.views.FilterView``. -You must provide either a ``model`` or ``filterset_class`` argument, similar to -``ListView`` in Django itself:: - - # urls.py - from django.conf.urls import patterns, url - from django_filters.views import FilterView - from myapp.models import Product - - urlpatterns = patterns('', - (r'^list/$', FilterView.as_view(model=Product)), - ) - -You must provide a template at ``/_filter.html`` which gets the -context parameter ``filter``. Additionally, the context will contain -``object_list`` which holds the filtered queryset. - -A legacy functional generic view is still included in django-filter, although -its use is deprecated. It can be found at -``django_filters.views.object_filter``. You must provide the same arguments -to it as the class based view:: - - # urls.py - from django.conf.urls import patterns, url - from myapp.models import Product - - urlpatterns = patterns('', - (r'^list/$', 'django_filters.views.object_filter', {'model': Product}), - ) - -The needed template and its context variables will also be the same as the -class-based view above. Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/ajax-loader.gif and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/ajax-loader.gif differ diff -Nru django-filter-0.11.0/docs/_build/html/_static/basic.css django-filter-0.13.0/docs/_build/html/_static/basic.css --- django-filter-0.11.0/docs/_build/html/_static/basic.css 2014-11-28 11:13:33.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_static/basic.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,537 +0,0 @@ -/* - * basic.css - * ~~~~~~~~~ - * - * Sphinx stylesheet -- basic theme. - * - * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. - * :license: BSD, see LICENSE for details. - * - */ - -/* -- main layout ----------------------------------------------------------- */ - -div.clearer { - clear: both; -} - -/* -- relbar ---------------------------------------------------------------- */ - -div.related { - width: 100%; - font-size: 90%; -} - -div.related h3 { - display: none; -} - -div.related ul { - margin: 0; - padding: 0 0 0 10px; - list-style: none; -} - -div.related li { - display: inline; -} - -div.related li.right { - float: right; - margin-right: 5px; -} - -/* -- sidebar --------------------------------------------------------------- */ - -div.sphinxsidebarwrapper { - padding: 10px 5px 0 10px; -} - -div.sphinxsidebar { - float: left; - width: 230px; - margin-left: -100%; - font-size: 90%; -} - -div.sphinxsidebar ul { - list-style: none; -} - -div.sphinxsidebar ul ul, -div.sphinxsidebar ul.want-points { - margin-left: 20px; - list-style: square; -} - -div.sphinxsidebar ul ul { - margin-top: 0; - margin-bottom: 0; -} - -div.sphinxsidebar form { - margin-top: 10px; -} - -div.sphinxsidebar input { - border: 1px solid #98dbcc; - font-family: sans-serif; - font-size: 1em; -} - -div.sphinxsidebar #searchbox input[type="text"] { - width: 170px; -} - -div.sphinxsidebar #searchbox input[type="submit"] { - width: 30px; -} - -img { - border: 0; - max-width: 100%; -} - -/* -- search page ----------------------------------------------------------- */ - -ul.search { - margin: 10px 0 0 20px; - padding: 0; -} - -ul.search li { - padding: 5px 0 5px 20px; - background-image: url(file.png); - background-repeat: no-repeat; - background-position: 0 7px; -} - -ul.search li a { - font-weight: bold; -} - -ul.search li div.context { - color: #888; - margin: 2px 0 0 30px; - text-align: left; -} - -ul.keywordmatches li.goodmatch a { - font-weight: bold; -} - -/* -- index page ------------------------------------------------------------ */ - -table.contentstable { - width: 90%; -} - -table.contentstable p.biglink { - line-height: 150%; -} - -a.biglink { - font-size: 1.3em; -} - -span.linkdescr { - font-style: italic; - padding-top: 5px; - font-size: 90%; -} - -/* -- general index --------------------------------------------------------- */ - -table.indextable { - width: 100%; -} - -table.indextable td { - text-align: left; - vertical-align: top; -} - -table.indextable dl, table.indextable dd { - margin-top: 0; - margin-bottom: 0; -} - -table.indextable tr.pcap { - height: 10px; -} - -table.indextable tr.cap { - margin-top: 10px; - background-color: #f2f2f2; -} - -img.toggler { - margin-right: 3px; - margin-top: 3px; - cursor: pointer; -} - -div.modindex-jumpbox { - border-top: 1px solid #ddd; - border-bottom: 1px solid #ddd; - margin: 1em 0 1em 0; - padding: 0.4em; -} - -div.genindex-jumpbox { - border-top: 1px solid #ddd; - border-bottom: 1px solid #ddd; - margin: 1em 0 1em 0; - padding: 0.4em; -} - -/* -- general body styles --------------------------------------------------- */ - -a.headerlink { - visibility: hidden; -} - -h1:hover > a.headerlink, -h2:hover > a.headerlink, -h3:hover > a.headerlink, -h4:hover > a.headerlink, -h5:hover > a.headerlink, -h6:hover > a.headerlink, -dt:hover > a.headerlink { - visibility: visible; -} - -div.body p.caption { - text-align: inherit; -} - -div.body td { - text-align: left; -} - -.field-list ul { - padding-left: 1em; -} - -.first { - margin-top: 0 !important; -} - -p.rubric { - margin-top: 30px; - font-weight: bold; -} - -img.align-left, .figure.align-left, object.align-left { - clear: left; - float: left; - margin-right: 1em; -} - -img.align-right, .figure.align-right, object.align-right { - clear: right; - float: right; - margin-left: 1em; -} - -img.align-center, .figure.align-center, object.align-center { - display: block; - margin-left: auto; - margin-right: auto; -} - -.align-left { - text-align: left; -} - -.align-center { - text-align: center; -} - -.align-right { - text-align: right; -} - -/* -- sidebars -------------------------------------------------------------- */ - -div.sidebar { - margin: 0 0 0.5em 1em; - border: 1px solid #ddb; - padding: 7px 7px 0 7px; - background-color: #ffe; - width: 40%; - float: right; -} - -p.sidebar-title { - font-weight: bold; -} - -/* -- topics ---------------------------------------------------------------- */ - -div.topic { - border: 1px solid #ccc; - padding: 7px 7px 0 7px; - margin: 10px 0 10px 0; -} - -p.topic-title { - font-size: 1.1em; - font-weight: bold; - margin-top: 10px; -} - -/* -- admonitions ----------------------------------------------------------- */ - -div.admonition { - margin-top: 10px; - margin-bottom: 10px; - padding: 7px; -} - -div.admonition dt { - font-weight: bold; -} - -div.admonition dl { - margin-bottom: 0; -} - -p.admonition-title { - margin: 0px 10px 5px 0px; - font-weight: bold; -} - -div.body p.centered { - text-align: center; - margin-top: 25px; -} - -/* -- tables ---------------------------------------------------------------- */ - -table.docutils { - border: 0; - border-collapse: collapse; -} - -table.docutils td, table.docutils th { - padding: 1px 8px 1px 5px; - border-top: 0; - border-left: 0; - border-right: 0; - border-bottom: 1px solid #aaa; -} - -table.field-list td, table.field-list th { - border: 0 !important; -} - -table.footnote td, table.footnote th { - border: 0 !important; -} - -th { - text-align: left; - padding-right: 5px; -} - -table.citation { - border-left: solid 1px gray; - margin-left: 1px; -} - -table.citation td { - border-bottom: none; -} - -/* -- other body styles ----------------------------------------------------- */ - -ol.arabic { - list-style: decimal; -} - -ol.loweralpha { - list-style: lower-alpha; -} - -ol.upperalpha { - list-style: upper-alpha; -} - -ol.lowerroman { - list-style: lower-roman; -} - -ol.upperroman { - list-style: upper-roman; -} - -dl { - margin-bottom: 15px; -} - -dd p { - margin-top: 0px; -} - -dd ul, dd table { - margin-bottom: 10px; -} - -dd { - margin-top: 3px; - margin-bottom: 10px; - margin-left: 30px; -} - -dt:target, .highlighted { - background-color: #fbe54e; -} - -dl.glossary dt { - font-weight: bold; - font-size: 1.1em; -} - -.field-list ul { - margin: 0; - padding-left: 1em; -} - -.field-list p { - margin: 0; -} - -.optional { - font-size: 1.3em; -} - -.versionmodified { - font-style: italic; -} - -.system-message { - background-color: #fda; - padding: 5px; - border: 3px solid red; -} - -.footnote:target { - background-color: #ffa; -} - -.line-block { - display: block; - margin-top: 1em; - margin-bottom: 1em; -} - -.line-block .line-block { - margin-top: 0; - margin-bottom: 0; - margin-left: 1.5em; -} - -.guilabel, .menuselection { - font-family: sans-serif; -} - -.accelerator { - text-decoration: underline; -} - -.classifier { - font-style: oblique; -} - -abbr, acronym { - border-bottom: dotted 1px; - cursor: help; -} - -/* -- code displays --------------------------------------------------------- */ - -pre { - overflow: auto; - overflow-y: hidden; /* fixes display issues on Chrome browsers */ -} - -td.linenos pre { - padding: 5px 0px; - border: 0; - background-color: transparent; - color: #aaa; -} - -table.highlighttable { - margin-left: 0.5em; -} - -table.highlighttable td { - padding: 0 0.5em 0 0.5em; -} - -tt.descname { - background-color: transparent; - font-weight: bold; - font-size: 1.2em; -} - -tt.descclassname { - background-color: transparent; -} - -tt.xref, a tt { - background-color: transparent; - font-weight: bold; -} - -h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { - background-color: transparent; -} - -.viewcode-link { - float: right; -} - -.viewcode-back { - float: right; - font-family: sans-serif; -} - -div.viewcode-block:target { - margin: -1px -10px; - padding: 0 10px; -} - -/* -- math display ---------------------------------------------------------- */ - -img.math { - vertical-align: middle; -} - -div.body div.math p { - text-align: center; -} - -span.eqno { - float: right; -} - -/* -- printout stylesheet --------------------------------------------------- */ - -@media print { - div.document, - div.documentwrapper, - div.bodywrapper { - margin: 0 !important; - width: 100%; - } - - div.sphinxsidebar, - div.related, - div.footer, - #top-link { - display: none; - } -} \ No newline at end of file Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/comment-bright.png and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/comment-bright.png differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/comment-close.png and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/comment-close.png differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/comment.png and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/comment.png differ diff -Nru django-filter-0.11.0/docs/_build/html/_static/default.css django-filter-0.13.0/docs/_build/html/_static/default.css --- django-filter-0.11.0/docs/_build/html/_static/default.css 2014-11-28 11:13:33.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_static/default.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,256 +0,0 @@ -/* - * default.css_t - * ~~~~~~~~~~~~~ - * - * Sphinx stylesheet -- default theme. - * - * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. - * :license: BSD, see LICENSE for details. - * - */ - -@import url("basic.css"); - -/* -- page layout ----------------------------------------------------------- */ - -body { - font-family: sans-serif; - font-size: 100%; - background-color: #11303d; - color: #000; - margin: 0; - padding: 0; -} - -div.document { - background-color: #1c4e63; -} - -div.documentwrapper { - float: left; - width: 100%; -} - -div.bodywrapper { - margin: 0 0 0 230px; -} - -div.body { - background-color: #ffffff; - color: #000000; - padding: 0 20px 30px 20px; -} - -div.footer { - color: #ffffff; - width: 100%; - padding: 9px 0 9px 0; - text-align: center; - font-size: 75%; -} - -div.footer a { - color: #ffffff; - text-decoration: underline; -} - -div.related { - background-color: #133f52; - line-height: 30px; - color: #ffffff; -} - -div.related a { - color: #ffffff; -} - -div.sphinxsidebar { -} - -div.sphinxsidebar h3 { - font-family: 'Trebuchet MS', sans-serif; - color: #ffffff; - font-size: 1.4em; - font-weight: normal; - margin: 0; - padding: 0; -} - -div.sphinxsidebar h3 a { - color: #ffffff; -} - -div.sphinxsidebar h4 { - font-family: 'Trebuchet MS', sans-serif; - color: #ffffff; - font-size: 1.3em; - font-weight: normal; - margin: 5px 0 0 0; - padding: 0; -} - -div.sphinxsidebar p { - color: #ffffff; -} - -div.sphinxsidebar p.topless { - margin: 5px 10px 10px 10px; -} - -div.sphinxsidebar ul { - margin: 10px; - padding: 0; - color: #ffffff; -} - -div.sphinxsidebar a { - color: #98dbcc; -} - -div.sphinxsidebar input { - border: 1px solid #98dbcc; - font-family: sans-serif; - font-size: 1em; -} - - - -/* -- hyperlink styles ------------------------------------------------------ */ - -a { - color: #355f7c; - text-decoration: none; -} - -a:visited { - color: #355f7c; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - - - -/* -- body styles ----------------------------------------------------------- */ - -div.body h1, -div.body h2, -div.body h3, -div.body h4, -div.body h5, -div.body h6 { - font-family: 'Trebuchet MS', sans-serif; - background-color: #f2f2f2; - font-weight: normal; - color: #20435c; - border-bottom: 1px solid #ccc; - margin: 20px -20px 10px -20px; - padding: 3px 0 3px 10px; -} - -div.body h1 { margin-top: 0; font-size: 200%; } -div.body h2 { font-size: 160%; } -div.body h3 { font-size: 140%; } -div.body h4 { font-size: 120%; } -div.body h5 { font-size: 110%; } -div.body h6 { font-size: 100%; } - -a.headerlink { - color: #c60f0f; - font-size: 0.8em; - padding: 0 4px 0 4px; - text-decoration: none; -} - -a.headerlink:hover { - background-color: #c60f0f; - color: white; -} - -div.body p, div.body dd, div.body li { - text-align: justify; - line-height: 130%; -} - -div.admonition p.admonition-title + p { - display: inline; -} - -div.admonition p { - margin-bottom: 5px; -} - -div.admonition pre { - margin-bottom: 5px; -} - -div.admonition ul, div.admonition ol { - margin-bottom: 5px; -} - -div.note { - background-color: #eee; - border: 1px solid #ccc; -} - -div.seealso { - background-color: #ffc; - border: 1px solid #ff6; -} - -div.topic { - background-color: #eee; -} - -div.warning { - background-color: #ffe4e4; - border: 1px solid #f66; -} - -p.admonition-title { - display: inline; -} - -p.admonition-title:after { - content: ":"; -} - -pre { - padding: 5px; - background-color: #eeffcc; - color: #333333; - line-height: 120%; - border: 1px solid #ac9; - border-left: none; - border-right: none; -} - -tt { - background-color: #ecf0f3; - padding: 0 1px 0 1px; - font-size: 0.95em; -} - -th { - background-color: #ede; -} - -.warning tt { - background: #efc2c2; -} - -.note tt { - background: #d6d6d6; -} - -.viewcode-back { - font-family: sans-serif; -} - -div.viewcode-block:target { - background-color: #f4debf; - border-top: 1px solid #ac9; - border-bottom: 1px solid #ac9; -} \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/_static/doctools.js django-filter-0.13.0/docs/_build/html/_static/doctools.js --- django-filter-0.11.0/docs/_build/html/_static/doctools.js 2014-11-25 20:16:57.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_static/doctools.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,238 +0,0 @@ -/* - * doctools.js - * ~~~~~~~~~~~ - * - * Sphinx JavaScript utilities for all documentation. - * - * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. - * :license: BSD, see LICENSE for details. - * - */ - -/** - * select a different prefix for underscore - */ -$u = _.noConflict(); - -/** - * make the code below compatible with browsers without - * an installed firebug like debugger -if (!window.console || !console.firebug) { - var names = ["log", "debug", "info", "warn", "error", "assert", "dir", - "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", - "profile", "profileEnd"]; - window.console = {}; - for (var i = 0; i < names.length; ++i) - window.console[names[i]] = function() {}; -} - */ - -/** - * small helper function to urldecode strings - */ -jQuery.urldecode = function(x) { - return decodeURIComponent(x).replace(/\+/g, ' '); -}; - -/** - * small helper function to urlencode strings - */ -jQuery.urlencode = encodeURIComponent; - -/** - * This function returns the parsed url parameters of the - * current request. Multiple values per key are supported, - * it will always return arrays of strings for the value parts. - */ -jQuery.getQueryParameters = function(s) { - if (typeof s == 'undefined') - s = document.location.search; - var parts = s.substr(s.indexOf('?') + 1).split('&'); - var result = {}; - for (var i = 0; i < parts.length; i++) { - var tmp = parts[i].split('=', 2); - var key = jQuery.urldecode(tmp[0]); - var value = jQuery.urldecode(tmp[1]); - if (key in result) - result[key].push(value); - else - result[key] = [value]; - } - return result; -}; - -/** - * highlight a given string on a jquery object by wrapping it in - * span elements with the given class name. - */ -jQuery.fn.highlightText = function(text, className) { - function highlight(node) { - if (node.nodeType == 3) { - var val = node.nodeValue; - var pos = val.toLowerCase().indexOf(text); - if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) { - var span = document.createElement("span"); - span.className = className; - span.appendChild(document.createTextNode(val.substr(pos, text.length))); - node.parentNode.insertBefore(span, node.parentNode.insertBefore( - document.createTextNode(val.substr(pos + text.length)), - node.nextSibling)); - node.nodeValue = val.substr(0, pos); - } - } - else if (!jQuery(node).is("button, select, textarea")) { - jQuery.each(node.childNodes, function() { - highlight(this); - }); - } - } - return this.each(function() { - highlight(this); - }); -}; - -/** - * Small JavaScript module for the documentation. - */ -var Documentation = { - - init : function() { - this.fixFirefoxAnchorBug(); - this.highlightSearchWords(); - this.initIndexTable(); - }, - - /** - * i18n support - */ - TRANSLATIONS : {}, - PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; }, - LOCALE : 'unknown', - - // gettext and ngettext don't access this so that the functions - // can safely bound to a different name (_ = Documentation.gettext) - gettext : function(string) { - var translated = Documentation.TRANSLATIONS[string]; - if (typeof translated == 'undefined') - return string; - return (typeof translated == 'string') ? translated : translated[0]; - }, - - ngettext : function(singular, plural, n) { - var translated = Documentation.TRANSLATIONS[singular]; - if (typeof translated == 'undefined') - return (n == 1) ? singular : plural; - return translated[Documentation.PLURALEXPR(n)]; - }, - - addTranslations : function(catalog) { - for (var key in catalog.messages) - this.TRANSLATIONS[key] = catalog.messages[key]; - this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); - this.LOCALE = catalog.locale; - }, - - /** - * add context elements like header anchor links - */ - addContextElements : function() { - $('div[id] > :header:first').each(function() { - $('
\u00B6'). - attr('href', '#' + this.id). - attr('title', _('Permalink to this headline')). - appendTo(this); - }); - $('dt[id]').each(function() { - $('\u00B6'). - attr('href', '#' + this.id). - attr('title', _('Permalink to this definition')). - appendTo(this); - }); - }, - - /** - * workaround a firefox stupidity - */ - fixFirefoxAnchorBug : function() { - if (document.location.hash && $.browser.mozilla) - window.setTimeout(function() { - document.location.href += ''; - }, 10); - }, - - /** - * highlight the search words provided in the url in the text - */ - highlightSearchWords : function() { - var params = $.getQueryParameters(); - var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; - if (terms.length) { - var body = $('div.body'); - if (!body.length) { - body = $('body'); - } - window.setTimeout(function() { - $.each(terms, function() { - body.highlightText(this.toLowerCase(), 'highlighted'); - }); - }, 10); - $('') - .appendTo($('#searchbox')); - } - }, - - /** - * init the domain index toggle buttons - */ - initIndexTable : function() { - var togglers = $('img.toggler').click(function() { - var src = $(this).attr('src'); - var idnum = $(this).attr('id').substr(7); - $('tr.cg-' + idnum).toggle(); - if (src.substr(-9) == 'minus.png') - $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); - else - $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); - }).css('display', ''); - if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { - togglers.click(); - } - }, - - /** - * helper function to hide the search marks again - */ - hideSearchWords : function() { - $('#searchbox .highlight-link').fadeOut(300); - $('span.highlighted').removeClass('highlighted'); - }, - - /** - * make the url absolute - */ - makeURL : function(relativeURL) { - return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; - }, - - /** - * get the current relative url - */ - getCurrentURL : function() { - var path = document.location.pathname; - var parts = path.split(/\//); - $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { - if (this == '..') - parts.pop(); - }); - var url = parts.join('/'); - return path.substring(url.lastIndexOf('/') + 1, path.length - 1); - } -}; - -// quick alias for translations -_ = Documentation.gettext; - -$(document).ready(function() { - Documentation.init(); -}); Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/down.png and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/down.png differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/down-pressed.png and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/down-pressed.png differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/file.png and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/file.png differ diff -Nru django-filter-0.11.0/docs/_build/html/_static/jquery.js django-filter-0.13.0/docs/_build/html/_static/jquery.js --- django-filter-0.11.0/docs/_build/html/_static/jquery.js 2014-11-25 20:16:57.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_static/jquery.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/*! jQuery v1.8.3 jquery.com | jquery.org/license */ -(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write(""),Ht.close();t=Ht.body.appendChild(Ht.createElement(e)),n=Dt(t,"display"),i.body.removeChild(Pt)}return Wt[e]=n,n}function fn(e,t,n,r){var i;if(v.isArray(t))v.each(t,function(t,i){n||sn.test(e)?r(e,i):fn(e+"["+(typeof i=="object"?t:"")+"]",i,n,r)});else if(!n&&v.type(t)==="object")for(i in t)fn(e+"["+i+"]",t[i],n,r);else r(e,t)}function Cn(e){return function(t,n){typeof t!="string"&&(n=t,t="*");var r,i,s,o=t.toLowerCase().split(y),u=0,a=o.length;if(v.isFunction(n))for(;u)[^>]*$|#([\w\-]*)$)/,E=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,S=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,T=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,N=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,C=/^-ms-/,k=/-([\da-z])/gi,L=function(e,t){return(t+"").toUpperCase()},A=function(){i.addEventListener?(i.removeEventListener("DOMContentLoaded",A,!1),v.ready()):i.readyState==="complete"&&(i.detachEvent("onreadystatechange",A),v.ready())},O={};v.fn=v.prototype={constructor:v,init:function(e,n,r){var s,o,u,a;if(!e)return this;if(e.nodeType)return this.context=this[0]=e,this.length=1,this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?s=[null,e,null]:s=w.exec(e);if(s&&(s[1]||!n)){if(s[1])return n=n instanceof v?n[0]:n,a=n&&n.nodeType?n.ownerDocument||n:i,e=v.parseHTML(s[1],a,!0),E.test(s[1])&&v.isPlainObject(n)&&this.attr.call(e,n,!0),v.merge(this,e);o=i.getElementById(s[2]);if(o&&o.parentNode){if(o.id!==s[2])return r.find(e);this.length=1,this[0]=o}return this.context=i,this.selector=e,this}return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e)}return v.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),v.makeArray(e,this))},selector:"",jquery:"1.8.3",length:0,size:function(){return this.length},toArray:function(){return l.call(this)},get:function(e){return e==null?this.toArray():e<0?this[this.length+e]:this[e]},pushStack:function(e,t,n){var r=v.merge(this.constructor(),e);return r.prevObject=this,r.context=this.context,t==="find"?r.selector=this.selector+(this.selector?" ":"")+n:t&&(r.selector=this.selector+"."+t+"("+n+")"),r},each:function(e,t){return v.each(this,e,t)},ready:function(e){return v.ready.promise().done(e),this},eq:function(e){return e=+e,e===-1?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(l.apply(this,arguments),"slice",l.call(arguments).join(","))},map:function(e){return this.pushStack(v.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},v.fn.init.prototype=v.fn,v.extend=v.fn.extend=function(){var e,n,r,i,s,o,u=arguments[0]||{},a=1,f=arguments.length,l=!1;typeof u=="boolean"&&(l=u,u=arguments[1]||{},a=2),typeof u!="object"&&!v.isFunction(u)&&(u={}),f===a&&(u=this,--a);for(;a0)return;r.resolveWith(i,[v]),v.fn.trigger&&v(i).trigger("ready").off("ready")},isFunction:function(e){return v.type(e)==="function"},isArray:Array.isArray||function(e){return v.type(e)==="array"},isWindow:function(e){return e!=null&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return e==null?String(e):O[h.call(e)]||"object"},isPlainObject:function(e){if(!e||v.type(e)!=="object"||e.nodeType||v.isWindow(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||p.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw new Error(e)},parseHTML:function(e,t,n){var r;return!e||typeof e!="string"?null:(typeof t=="boolean"&&(n=t,t=0),t=t||i,(r=E.exec(e))?[t.createElement(r[1])]:(r=v.buildFragment([e],t,n?null:[]),v.merge([],(r.cacheable?v.clone(r.fragment):r.fragment).childNodes)))},parseJSON:function(t){if(!t||typeof t!="string")return null;t=v.trim(t);if(e.JSON&&e.JSON.parse)return e.JSON.parse(t);if(S.test(t.replace(T,"@").replace(N,"]").replace(x,"")))return(new Function("return "+t))();v.error("Invalid JSON: "+t)},parseXML:function(n){var r,i;if(!n||typeof n!="string")return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(s){r=t}return(!r||!r.documentElement||r.getElementsByTagName("parsererror").length)&&v.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&g.test(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(C,"ms-").replace(k,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,n,r){var i,s=0,o=e.length,u=o===t||v.isFunction(e);if(r){if(u){for(i in e)if(n.apply(e[i],r)===!1)break}else for(;s0&&e[0]&&e[a-1]||a===0||v.isArray(e));if(f)for(;u-1)a.splice(n,1),i&&(n<=o&&o--,n<=u&&u--)}),this},has:function(e){return v.inArray(e,a)>-1},empty:function(){return a=[],this},disable:function(){return a=f=n=t,this},disabled:function(){return!a},lock:function(){return f=t,n||c.disable(),this},locked:function(){return!f},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],a&&(!r||f)&&(i?f.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},v.extend({Deferred:function(e){var t=[["resolve","done",v.Callbacks("once memory"),"resolved"],["reject","fail",v.Callbacks("once memory"),"rejected"],["notify","progress",v.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return v.Deferred(function(n){v.each(t,function(t,r){var s=r[0],o=e[t];i[r[1]](v.isFunction(o)?function(){var e=o.apply(this,arguments);e&&v.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===i?n:this,[e])}:n[s])}),e=null}).promise()},promise:function(e){return e!=null?v.extend(e,r):r}},i={};return r.pipe=r.then,v.each(t,function(e,s){var o=s[2],u=s[3];r[s[1]]=o.add,u&&o.add(function(){n=u},t[e^1][2].disable,t[2][2].lock),i[s[0]]=o.fire,i[s[0]+"With"]=o.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=l.call(arguments),r=n.length,i=r!==1||e&&v.isFunction(e.promise)?r:0,s=i===1?e:v.Deferred(),o=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?l.call(arguments):r,n===u?s.notifyWith(t,n):--i||s.resolveWith(t,n)}},u,a,f;if(r>1){u=new Array(r),a=new Array(r),f=new Array(r);for(;t
a",n=p.getElementsByTagName("*"),r=p.getElementsByTagName("a")[0];if(!n||!r||!n.length)return{};s=i.createElement("select"),o=s.appendChild(i.createElement("option")),u=p.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:r.getAttribute("href")==="/a",opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:u.value==="on",optSelected:o.selected,getSetAttribute:p.className!=="t",enctype:!!i.createElement("form").enctype,html5Clone:i.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",boxModel:i.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},u.checked=!0,t.noCloneChecked=u.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!o.disabled;try{delete p.test}catch(d){t.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",h=function(){t.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick"),p.detachEvent("onclick",h)),u=i.createElement("input"),u.value="t",u.setAttribute("type","radio"),t.radioValue=u.value==="t",u.setAttribute("checked","checked"),u.setAttribute("name","t"),p.appendChild(u),a=i.createDocumentFragment(),a.appendChild(p.lastChild),t.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,t.appendChecked=u.checked,a.removeChild(u),a.appendChild(p);if(p.attachEvent)for(l in{submit:!0,change:!0,focusin:!0})f="on"+l,c=f in p,c||(p.setAttribute(f,"return;"),c=typeof p[f]=="function"),t[l+"Bubbles"]=c;return v(function(){var n,r,s,o,u="padding:0;margin:0;border:0;display:block;overflow:hidden;",a=i.getElementsByTagName("body")[0];if(!a)return;n=i.createElement("div"),n.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",a.insertBefore(n,a.firstChild),r=i.createElement("div"),n.appendChild(r),r.innerHTML="
t
",s=r.getElementsByTagName("td"),s[0].style.cssText="padding:0;margin:0;border:0;display:none",c=s[0].offsetHeight===0,s[0].style.display="",s[1].style.display="none",t.reliableHiddenOffsets=c&&s[0].offsetHeight===0,r.innerHTML="",r.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=r.offsetWidth===4,t.doesNotIncludeMarginInBodyOffset=a.offsetTop!==1,e.getComputedStyle&&(t.pixelPosition=(e.getComputedStyle(r,null)||{}).top!=="1%",t.boxSizingReliable=(e.getComputedStyle(r,null)||{width:"4px"}).width==="4px",o=i.createElement("div"),o.style.cssText=r.style.cssText=u,o.style.marginRight=o.style.width="0",r.style.width="1px",r.appendChild(o),t.reliableMarginRight=!parseFloat((e.getComputedStyle(o,null)||{}).marginRight)),typeof r.style.zoom!="undefined"&&(r.innerHTML="",r.style.cssText=u+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=r.offsetWidth===3,r.style.display="block",r.style.overflow="visible",r.innerHTML="
",r.firstChild.style.width="5px",t.shrinkWrapBlocks=r.offsetWidth!==3,n.style.zoom=1),a.removeChild(n),n=r=s=o=null}),a.removeChild(p),n=r=s=o=u=a=p=null,t}();var D=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;v.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(v.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?v.cache[e[v.expando]]:e[v.expando],!!e&&!B(e)},data:function(e,n,r,i){if(!v.acceptData(e))return;var s,o,u=v.expando,a=typeof n=="string",f=e.nodeType,l=f?v.cache:e,c=f?e[u]:e[u]&&u;if((!c||!l[c]||!i&&!l[c].data)&&a&&r===t)return;c||(f?e[u]=c=v.deletedIds.pop()||v.guid++:c=u),l[c]||(l[c]={},f||(l[c].toJSON=v.noop));if(typeof n=="object"||typeof n=="function")i?l[c]=v.extend(l[c],n):l[c].data=v.extend(l[c].data,n);return s=l[c],i||(s.data||(s.data={}),s=s.data),r!==t&&(s[v.camelCase(n)]=r),a?(o=s[n],o==null&&(o=s[v.camelCase(n)])):o=s,o},removeData:function(e,t,n){if(!v.acceptData(e))return;var r,i,s,o=e.nodeType,u=o?v.cache:e,a=o?e[v.expando]:v.expando;if(!u[a])return;if(t){r=n?u[a]:u[a].data;if(r){v.isArray(t)||(t in r?t=[t]:(t=v.camelCase(t),t in r?t=[t]:t=t.split(" ")));for(i=0,s=t.length;i1,null,!1))},removeData:function(e){return this.each(function(){v.removeData(this,e)})}}),v.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=v._data(e,t),n&&(!r||v.isArray(n)?r=v._data(e,t,v.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=v.queue(e,t),r=n.length,i=n.shift(),s=v._queueHooks(e,t),o=function(){v.dequeue(e,t)};i==="inprogress"&&(i=n.shift(),r--),i&&(t==="fx"&&n.unshift("inprogress"),delete s.stop,i.call(e,o,s)),!r&&s&&s.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return v._data(e,n)||v._data(e,n,{empty:v.Callbacks("once memory").add(function(){v.removeData(e,t+"queue",!0),v.removeData(e,n,!0)})})}}),v.fn.extend({queue:function(e,n){var r=2;return typeof e!="string"&&(n=e,e="fx",r--),arguments.length1)},removeAttr:function(e){return this.each(function(){v.removeAttr(this,e)})},prop:function(e,t){return v.access(this,v.prop,e,t,arguments.length>1)},removeProp:function(e){return e=v.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,s,o,u;if(v.isFunction(e))return this.each(function(t){v(this).addClass(e.call(this,t,this.className))});if(e&&typeof e=="string"){t=e.split(y);for(n=0,r=this.length;n=0)r=r.replace(" "+n[s]+" "," ");i.className=e?v.trim(r):""}}}return this},toggleClass:function(e,t){var n=typeof e,r=typeof t=="boolean";return v.isFunction(e)?this.each(function(n){v(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(n==="string"){var i,s=0,o=v(this),u=t,a=e.split(y);while(i=a[s++])u=r?u:!o.hasClass(i),o[u?"addClass":"removeClass"](i)}else if(n==="undefined"||n==="boolean")this.className&&v._data(this,"__className__",this.className),this.className=this.className||e===!1?"":v._data(this,"__className__")||""})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;n=0)return!0;return!1},val:function(e){var n,r,i,s=this[0];if(!arguments.length){if(s)return n=v.valHooks[s.type]||v.valHooks[s.nodeName.toLowerCase()],n&&"get"in n&&(r=n.get(s,"value"))!==t?r:(r=s.value,typeof r=="string"?r.replace(R,""):r==null?"":r);return}return i=v.isFunction(e),this.each(function(r){var s,o=v(this);if(this.nodeType!==1)return;i?s=e.call(this,r,o.val()):s=e,s==null?s="":typeof s=="number"?s+="":v.isArray(s)&&(s=v.map(s,function(e){return e==null?"":e+""})),n=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()];if(!n||!("set"in n)||n.set(this,s,"value")===t)this.value=s})}}),v.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,s=e.type==="select-one"||i<0,o=s?null:[],u=s?i+1:r.length,a=i<0?u:s?i:0;for(;a=0}),n.length||(e.selectedIndex=-1),n}}},attrFn:{},attr:function(e,n,r,i){var s,o,u,a=e.nodeType;if(!e||a===3||a===8||a===2)return;if(i&&v.isFunction(v.fn[n]))return v(e)[n](r);if(typeof e.getAttribute=="undefined")return v.prop(e,n,r);u=a!==1||!v.isXMLDoc(e),u&&(n=n.toLowerCase(),o=v.attrHooks[n]||(X.test(n)?F:j));if(r!==t){if(r===null){v.removeAttr(e,n);return}return o&&"set"in o&&u&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r)}return o&&"get"in o&&u&&(s=o.get(e,n))!==null?s:(s=e.getAttribute(n),s===null?t:s)},removeAttr:function(e,t){var n,r,i,s,o=0;if(t&&e.nodeType===1){r=t.split(y);for(;o=0}})});var $=/^(?:textarea|input|select)$/i,J=/^([^\.]*|)(?:\.(.+)|)$/,K=/(?:^|\s)hover(\.\S+|)\b/,Q=/^key/,G=/^(?:mouse|contextmenu)|click/,Y=/^(?:focusinfocus|focusoutblur)$/,Z=function(e){return v.event.special.hover?e:e.replace(K,"mouseenter$1 mouseleave$1")};v.event={add:function(e,n,r,i,s){var o,u,a,f,l,c,h,p,d,m,g;if(e.nodeType===3||e.nodeType===8||!n||!r||!(o=v._data(e)))return;r.handler&&(d=r,r=d.handler,s=d.selector),r.guid||(r.guid=v.guid++),a=o.events,a||(o.events=a={}),u=o.handle,u||(o.handle=u=function(e){return typeof v=="undefined"||!!e&&v.event.triggered===e.type?t:v.event.dispatch.apply(u.elem,arguments)},u.elem=e),n=v.trim(Z(n)).split(" ");for(f=0;f=0&&(y=y.slice(0,-1),a=!0),y.indexOf(".")>=0&&(b=y.split("."),y=b.shift(),b.sort());if((!s||v.event.customEvent[y])&&!v.event.global[y])return;n=typeof n=="object"?n[v.expando]?n:new v.Event(y,n):new v.Event(y),n.type=y,n.isTrigger=!0,n.exclusive=a,n.namespace=b.join("."),n.namespace_re=n.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,h=y.indexOf(":")<0?"on"+y:"";if(!s){u=v.cache;for(f in u)u[f].events&&u[f].events[y]&&v.event.trigger(n,r,u[f].handle.elem,!0);return}n.result=t,n.target||(n.target=s),r=r!=null?v.makeArray(r):[],r.unshift(n),p=v.event.special[y]||{};if(p.trigger&&p.trigger.apply(s,r)===!1)return;m=[[s,p.bindType||y]];if(!o&&!p.noBubble&&!v.isWindow(s)){g=p.delegateType||y,l=Y.test(g+y)?s:s.parentNode;for(c=s;l;l=l.parentNode)m.push([l,g]),c=l;c===(s.ownerDocument||i)&&m.push([c.defaultView||c.parentWindow||e,g])}for(f=0;f=0:v.find(h,this,null,[s]).length),u[h]&&f.push(c);f.length&&w.push({elem:s,matches:f})}d.length>m&&w.push({elem:this,matches:d.slice(m)});for(r=0;r0?this.on(t,null,e,n):this.trigger(t)},Q.test(t)&&(v.event.fixHooks[t]=v.event.keyHooks),G.test(t)&&(v.event.fixHooks[t]=v.event.mouseHooks)}),function(e,t){function nt(e,t,n,r){n=n||[],t=t||g;var i,s,a,f,l=t.nodeType;if(!e||typeof e!="string")return n;if(l!==1&&l!==9)return[];a=o(t);if(!a&&!r)if(i=R.exec(e))if(f=i[1]){if(l===9){s=t.getElementById(f);if(!s||!s.parentNode)return n;if(s.id===f)return n.push(s),n}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(f))&&u(t,s)&&s.id===f)return n.push(s),n}else{if(i[2])return S.apply(n,x.call(t.getElementsByTagName(e),0)),n;if((f=i[3])&&Z&&t.getElementsByClassName)return S.apply(n,x.call(t.getElementsByClassName(f),0)),n}return vt(e.replace(j,"$1"),t,n,r,a)}function rt(e){return function(t){var n=t.nodeName.toLowerCase();return n==="input"&&t.type===e}}function it(e){return function(t){var n=t.nodeName.toLowerCase();return(n==="input"||n==="button")&&t.type===e}}function st(e){return N(function(t){return t=+t,N(function(n,r){var i,s=e([],n.length,t),o=s.length;while(o--)n[i=s[o]]&&(n[i]=!(r[i]=n[i]))})})}function ot(e,t,n){if(e===t)return n;var r=e.nextSibling;while(r){if(r===t)return-1;r=r.nextSibling}return 1}function ut(e,t){var n,r,s,o,u,a,f,l=L[d][e+" "];if(l)return t?0:l.slice(0);u=e,a=[],f=i.preFilter;while(u){if(!n||(r=F.exec(u)))r&&(u=u.slice(r[0].length)||u),a.push(s=[]);n=!1;if(r=I.exec(u))s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=r[0].replace(j," ");for(o in i.filter)(r=J[o].exec(u))&&(!f[o]||(r=f[o](r)))&&(s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=o,n.matches=r);if(!n)break}return t?u.length:u?nt.error(e):L(e,a).slice(0)}function at(e,t,r){var i=t.dir,s=r&&t.dir==="parentNode",o=w++;return t.first?function(t,n,r){while(t=t[i])if(s||t.nodeType===1)return e(t,n,r)}:function(t,r,u){if(!u){var a,f=b+" "+o+" ",l=f+n;while(t=t[i])if(s||t.nodeType===1){if((a=t[d])===l)return t.sizset;if(typeof a=="string"&&a.indexOf(f)===0){if(t.sizset)return t}else{t[d]=l;if(e(t,r,u))return t.sizset=!0,t;t.sizset=!1}}}else while(t=t[i])if(s||t.nodeType===1)if(e(t,r,u))return t}}function ft(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function lt(e,t,n,r,i){var s,o=[],u=0,a=e.length,f=t!=null;for(;u-1&&(s[f]=!(o[f]=c))}}else g=lt(g===o?g.splice(d,g.length):g),i?i(null,o,g,a):S.apply(o,g)})}function ht(e){var t,n,r,s=e.length,o=i.relative[e[0].type],u=o||i.relative[" "],a=o?1:0,f=at(function(e){return e===t},u,!0),l=at(function(e){return T.call(t,e)>-1},u,!0),h=[function(e,n,r){return!o&&(r||n!==c)||((t=n).nodeType?f(e,n,r):l(e,n,r))}];for(;a1&&ft(h),a>1&&e.slice(0,a-1).join("").replace(j,"$1"),n,a0,s=e.length>0,o=function(u,a,f,l,h){var p,d,v,m=[],y=0,w="0",x=u&&[],T=h!=null,N=c,C=u||s&&i.find.TAG("*",h&&a.parentNode||a),k=b+=N==null?1:Math.E;T&&(c=a!==g&&a,n=o.el);for(;(p=C[w])!=null;w++){if(s&&p){for(d=0;v=e[d];d++)if(v(p,a,f)){l.push(p);break}T&&(b=k,n=++o.el)}r&&((p=!v&&p)&&y--,u&&x.push(p))}y+=w;if(r&&w!==y){for(d=0;v=t[d];d++)v(x,m,a,f);if(u){if(y>0)while(w--)!x[w]&&!m[w]&&(m[w]=E.call(l));m=lt(m)}S.apply(l,m),T&&!u&&m.length>0&&y+t.length>1&&nt.uniqueSort(l)}return T&&(b=k,c=N),x};return o.el=0,r?N(o):o}function dt(e,t,n){var r=0,i=t.length;for(;r2&&(f=u[0]).type==="ID"&&t.nodeType===9&&!s&&i.relative[u[1].type]){t=i.find.ID(f.matches[0].replace($,""),t,s)[0];if(!t)return n;e=e.slice(u.shift().length)}for(o=J.POS.test(e)?-1:u.length-1;o>=0;o--){f=u[o];if(i.relative[l=f.type])break;if(c=i.find[l])if(r=c(f.matches[0].replace($,""),z.test(u[0].type)&&t.parentNode||t,s)){u.splice(o,1),e=r.length&&u.join("");if(!e)return S.apply(n,x.call(r,0)),n;break}}}return a(e,h)(r,t,s,n,z.test(e)),n}function mt(){}var n,r,i,s,o,u,a,f,l,c,h=!0,p="undefined",d=("sizcache"+Math.random()).replace(".",""),m=String,g=e.document,y=g.documentElement,b=0,w=0,E=[].pop,S=[].push,x=[].slice,T=[].indexOf||function(e){var t=0,n=this.length;for(;ti.cacheLength&&delete e[t.shift()],e[n+" "]=r},e)},k=C(),L=C(),A=C(),O="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",_=M.replace("w","w#"),D="([*^$|!~]?=)",P="\\["+O+"*("+M+")"+O+"*(?:"+D+O+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+_+")|)|)"+O+"*\\]",H=":("+M+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:"+P+")|[^:]|\\\\.)*|.*))\\)|)",B=":(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)",j=new RegExp("^"+O+"+|((?:^|[^\\\\])(?:\\\\.)*)"+O+"+$","g"),F=new RegExp("^"+O+"*,"+O+"*"),I=new RegExp("^"+O+"*([\\x20\\t\\r\\n\\f>+~])"+O+"*"),q=new RegExp(H),R=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,U=/^:not/,z=/[\x20\t\r\n\f]*[+~]/,W=/:not\($/,X=/h\d/i,V=/input|select|textarea|button/i,$=/\\(?!\\)/g,J={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),NAME:new RegExp("^\\[name=['\"]?("+M+")['\"]?\\]"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+H),POS:new RegExp(B,"i"),CHILD:new RegExp("^:(only|nth|first|last)-child(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),needsContext:new RegExp("^"+O+"*[>+~]|"+B,"i")},K=function(e){var t=g.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}},Q=K(function(e){return e.appendChild(g.createComment("")),!e.getElementsByTagName("*").length}),G=K(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==p&&e.firstChild.getAttribute("href")==="#"}),Y=K(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return t!=="boolean"&&t!=="string"}),Z=K(function(e){return e.innerHTML="",!e.getElementsByClassName||!e.getElementsByClassName("e").length?!1:(e.lastChild.className="e",e.getElementsByClassName("e").length===2)}),et=K(function(e){e.id=d+0,e.innerHTML="
",y.insertBefore(e,y.firstChild);var t=g.getElementsByName&&g.getElementsByName(d).length===2+g.getElementsByName(d+0).length;return r=!g.getElementById(d),y.removeChild(e),t});try{x.call(y.childNodes,0)[0].nodeType}catch(tt){x=function(e){var t,n=[];for(;t=this[e];e++)n.push(t);return n}}nt.matches=function(e,t){return nt(e,null,null,t)},nt.matchesSelector=function(e,t){return nt(t,null,null,[e]).length>0},s=nt.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(i===1||i===9||i===11){if(typeof e.textContent=="string")return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=s(e)}else if(i===3||i===4)return e.nodeValue}else for(;t=e[r];r++)n+=s(t);return n},o=nt.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?t.nodeName!=="HTML":!1},u=nt.contains=y.contains?function(e,t){var n=e.nodeType===9?e.documentElement:e,r=t&&t.parentNode;return e===r||!!(r&&r.nodeType===1&&n.contains&&n.contains(r))}:y.compareDocumentPosition?function(e,t){return t&&!!(e.compareDocumentPosition(t)&16)}:function(e,t){while(t=t.parentNode)if(t===e)return!0;return!1},nt.attr=function(e,t){var n,r=o(e);return r||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):r||Y?e.getAttribute(t):(n=e.getAttributeNode(t),n?typeof e[t]=="boolean"?e[t]?t:null:n.specified?n.value:null:null)},i=nt.selectors={cacheLength:50,createPseudo:N,match:J,attrHandle:G?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},find:{ID:r?function(e,t,n){if(typeof t.getElementById!==p&&!n){var r=t.getElementById(e);return r&&r.parentNode?[r]:[]}}:function(e,n,r){if(typeof n.getElementById!==p&&!r){var i=n.getElementById(e);return i?i.id===e||typeof i.getAttributeNode!==p&&i.getAttributeNode("id").value===e?[i]:t:[]}},TAG:Q?function(e,t){if(typeof t.getElementsByTagName!==p)return t.getElementsByTagName(e)}:function(e,t){var n=t.getElementsByTagName(e);if(e==="*"){var r,i=[],s=0;for(;r=n[s];s++)r.nodeType===1&&i.push(r);return i}return n},NAME:et&&function(e,t){if(typeof t.getElementsByName!==p)return t.getElementsByName(name)},CLASS:Z&&function(e,t,n){if(typeof t.getElementsByClassName!==p&&!n)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace($,""),e[3]=(e[4]||e[5]||"").replace($,""),e[2]==="~="&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),e[1]==="nth"?(e[2]||nt.error(e[0]),e[3]=+(e[3]?e[4]+(e[5]||1):2*(e[2]==="even"||e[2]==="odd")),e[4]=+(e[6]+e[7]||e[2]==="odd")):e[2]&&nt.error(e[0]),e},PSEUDO:function(e){var t,n;if(J.CHILD.test(e[0]))return null;if(e[3])e[2]=e[3];else if(t=e[4])q.test(t)&&(n=ut(t,!0))&&(n=t.indexOf(")",t.length-n)-t.length)&&(t=t.slice(0,n),e[0]=e[0].slice(0,n)),e[2]=t;return e.slice(0,3)}},filter:{ID:r?function(e){return e=e.replace($,""),function(t){return t.getAttribute("id")===e}}:function(e){return e=e.replace($,""),function(t){var n=typeof t.getAttributeNode!==p&&t.getAttributeNode("id");return n&&n.value===e}},TAG:function(e){return e==="*"?function(){return!0}:(e=e.replace($,"").toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[d][e+" "];return t||(t=new RegExp("(^|"+O+")"+e+"("+O+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==p&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r,i){var s=nt.attr(r,e);return s==null?t==="!=":t?(s+="",t==="="?s===n:t==="!="?s!==n:t==="^="?n&&s.indexOf(n)===0:t==="*="?n&&s.indexOf(n)>-1:t==="$="?n&&s.substr(s.length-n.length)===n:t==="~="?(" "+s+" ").indexOf(n)>-1:t==="|="?s===n||s.substr(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r){return e==="nth"?function(e){var t,i,s=e.parentNode;if(n===1&&r===0)return!0;if(s){i=0;for(t=s.firstChild;t;t=t.nextSibling)if(t.nodeType===1){i++;if(e===t)break}}return i-=r,i===n||i%n===0&&i/n>=0}:function(t){var n=t;switch(e){case"only":case"first":while(n=n.previousSibling)if(n.nodeType===1)return!1;if(e==="first")return!0;n=t;case"last":while(n=n.nextSibling)if(n.nodeType===1)return!1;return!0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||nt.error("unsupported pseudo: "+e);return r[d]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?N(function(e,n){var i,s=r(e,t),o=s.length;while(o--)i=T.call(e,s[o]),e[i]=!(n[i]=s[o])}):function(e){return r(e,0,n)}):r}},pseudos:{not:N(function(e){var t=[],n=[],r=a(e.replace(j,"$1"));return r[d]?N(function(e,t,n,i){var s,o=r(e,null,i,[]),u=e.length;while(u--)if(s=o[u])e[u]=!(t[u]=s)}):function(e,i,s){return t[0]=e,r(t,null,s,n),!n.pop()}}),has:N(function(e){return function(t){return nt(e,t).length>0}}),contains:N(function(e){return function(t){return(t.textContent||t.innerText||s(t)).indexOf(e)>-1}}),enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&!!e.checked||t==="option"&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},parent:function(e){return!i.pseudos.empty(e)},empty:function(e){var t;e=e.firstChild;while(e){if(e.nodeName>"@"||(t=e.nodeType)===3||t===4)return!1;e=e.nextSibling}return!0},header:function(e){return X.test(e.nodeName)},text:function(e){var t,n;return e.nodeName.toLowerCase()==="input"&&(t=e.type)==="text"&&((n=e.getAttribute("type"))==null||n.toLowerCase()===t)},radio:rt("radio"),checkbox:rt("checkbox"),file:rt("file"),password:rt("password"),image:rt("image"),submit:it("submit"),reset:it("reset"),button:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&e.type==="button"||t==="button"},input:function(e){return V.test(e.nodeName)},focus:function(e){var t=e.ownerDocument;return e===t.activeElement&&(!t.hasFocus||t.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},active:function(e){return e===e.ownerDocument.activeElement},first:st(function(){return[0]}),last:st(function(e,t){return[t-1]}),eq:st(function(e,t,n){return[n<0?n+t:n]}),even:st(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:st(function(e,t,n){for(var r=n<0?n+t:n;++r",e.querySelectorAll("[selected]").length||i.push("\\["+O+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||i.push(":checked")}),K(function(e){e.innerHTML="

",e.querySelectorAll("[test^='']").length&&i.push("[*^$]="+O+"*(?:\"\"|'')"),e.innerHTML="",e.querySelectorAll(":enabled").length||i.push(":enabled",":disabled")}),i=new RegExp(i.join("|")),vt=function(e,r,s,o,u){if(!o&&!u&&!i.test(e)){var a,f,l=!0,c=d,h=r,p=r.nodeType===9&&e;if(r.nodeType===1&&r.nodeName.toLowerCase()!=="object"){a=ut(e),(l=r.getAttribute("id"))?c=l.replace(n,"\\$&"):r.setAttribute("id",c),c="[id='"+c+"'] ",f=a.length;while(f--)a[f]=c+a[f].join("");h=z.test(e)&&r.parentNode||r,p=a.join(",")}if(p)try{return S.apply(s,x.call(h.querySelectorAll(p),0)),s}catch(v){}finally{l||r.removeAttribute("id")}}return t(e,r,s,o,u)},u&&(K(function(t){e=u.call(t,"div");try{u.call(t,"[test!='']:sizzle"),s.push("!=",H)}catch(n){}}),s=new RegExp(s.join("|")),nt.matchesSelector=function(t,n){n=n.replace(r,"='$1']");if(!o(t)&&!s.test(n)&&!i.test(n))try{var a=u.call(t,n);if(a||e||t.document&&t.document.nodeType!==11)return a}catch(f){}return nt(n,null,null,[t]).length>0})}(),i.pseudos.nth=i.pseudos.eq,i.filters=mt.prototype=i.pseudos,i.setFilters=new mt,nt.attr=v.attr,v.find=nt,v.expr=nt.selectors,v.expr[":"]=v.expr.pseudos,v.unique=nt.uniqueSort,v.text=nt.getText,v.isXMLDoc=nt.isXML,v.contains=nt.contains}(e);var nt=/Until$/,rt=/^(?:parents|prev(?:Until|All))/,it=/^.[^:#\[\.,]*$/,st=v.expr.match.needsContext,ot={children:!0,contents:!0,next:!0,prev:!0};v.fn.extend({find:function(e){var t,n,r,i,s,o,u=this;if(typeof e!="string")return v(e).filter(function(){for(t=0,n=u.length;t0)for(i=r;i=0:v.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,s=[],o=st.test(e)||typeof e!="string"?v(e,t||this.context):0;for(;r-1:v.find.matchesSelector(n,e)){s.push(n);break}n=n.parentNode}}return s=s.length>1?v.unique(s):s,this.pushStack(s,"closest",e)},index:function(e){return e?typeof e=="string"?v.inArray(this[0],v(e)):v.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(e,t){var n=typeof e=="string"?v(e,t):v.makeArray(e&&e.nodeType?[e]:e),r=v.merge(this.get(),n);return this.pushStack(ut(n[0])||ut(r[0])?r:v.unique(r))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}}),v.fn.andSelf=v.fn.addBack,v.each({parent:function(e){var t=e.parentNode;return t&&t.nodeType!==11?t:null},parents:function(e){return v.dir(e,"parentNode")},parentsUntil:function(e,t,n){return v.dir(e,"parentNode",n)},next:function(e){return at(e,"nextSibling")},prev:function(e){return at(e,"previousSibling")},nextAll:function(e){return v.dir(e,"nextSibling")},prevAll:function(e){return v.dir(e,"previousSibling")},nextUntil:function(e,t,n){return v.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return v.dir(e,"previousSibling",n)},siblings:function(e){return v.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return v.sibling(e.firstChild)},contents:function(e){return v.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:v.merge([],e.childNodes)}},function(e,t){v.fn[e]=function(n,r){var i=v.map(this,t,n);return nt.test(e)||(r=n),r&&typeof r=="string"&&(i=v.filter(r,i)),i=this.length>1&&!ot[e]?v.unique(i):i,this.length>1&&rt.test(e)&&(i=i.reverse()),this.pushStack(i,e,l.call(arguments).join(","))}}),v.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),t.length===1?v.find.matchesSelector(t[0],e)?[t[0]]:[]:v.find.matches(e,t)},dir:function(e,n,r){var i=[],s=e[n];while(s&&s.nodeType!==9&&(r===t||s.nodeType!==1||!v(s).is(r)))s.nodeType===1&&i.push(s),s=s[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)e.nodeType===1&&e!==t&&n.push(e);return n}});var ct="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ht=/ jQuery\d+="(?:null|\d+)"/g,pt=/^\s+/,dt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,vt=/<([\w:]+)/,mt=/]","i"),Et=/^(?:checkbox|radio)$/,St=/checked\s*(?:[^=]|=\s*.checked.)/i,xt=/\/(java|ecma)script/i,Tt=/^\s*\s*$/g,Nt={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},Ct=lt(i),kt=Ct.appendChild(i.createElement("div"));Nt.optgroup=Nt.option,Nt.tbody=Nt.tfoot=Nt.colgroup=Nt.caption=Nt.thead,Nt.th=Nt.td,v.support.htmlSerialize||(Nt._default=[1,"X
","
"]),v.fn.extend({text:function(e){return v.access(this,function(e){return e===t?v.text(this):this.empty().append((this[0]&&this[0].ownerDocument||i).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(v.isFunction(e))return this.each(function(t){v(this).wrapAll(e.call(this,t))});if(this[0]){var t=v(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&e.firstChild.nodeType===1)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return v.isFunction(e)?this.each(function(t){v(this).wrapInner(e.call(this,t))}):this.each(function(){var t=v(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=v.isFunction(e);return this.each(function(n){v(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){v.nodeName(this,"body")||v(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(e,this.firstChild)})},before:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(e,this),"before",this.selector)}},after:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this.nextSibling)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(this,e),"after",this.selector)}},remove:function(e,t){var n,r=0;for(;(n=this[r])!=null;r++)if(!e||v.filter(e,[n]).length)!t&&n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),v.cleanData([n])),n.parentNode&&n.parentNode.removeChild(n);return this},empty:function(){var e,t=0;for(;(e=this[t])!=null;t++){e.nodeType===1&&v.cleanData(e.getElementsByTagName("*"));while(e.firstChild)e.removeChild(e.firstChild)}return this},clone:function(e,t){return e=e==null?!1:e,t=t==null?e:t,this.map(function(){return v.clone(this,e,t)})},html:function(e){return v.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return n.nodeType===1?n.innerHTML.replace(ht,""):t;if(typeof e=="string"&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(dt,"<$1>");try{for(;r1&&typeof f=="string"&&St.test(f))return this.each(function(){v(this).domManip(e,n,r)});if(v.isFunction(f))return this.each(function(i){var s=v(this);e[0]=f.call(this,i,n?s.html():t),s.domManip(e,n,r)});if(this[0]){i=v.buildFragment(e,this,l),o=i.fragment,s=o.firstChild,o.childNodes.length===1&&(o=s);if(s){n=n&&v.nodeName(s,"tr");for(u=i.cacheable||c-1;a0?this.clone(!0):this).get(),v(o[i])[t](r),s=s.concat(r);return this.pushStack(s,e,o.selector)}}),v.extend({clone:function(e,t,n){var r,i,s,o;v.support.html5Clone||v.isXMLDoc(e)||!wt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(kt.innerHTML=e.outerHTML,kt.removeChild(o=kt.firstChild));if((!v.support.noCloneEvent||!v.support.noCloneChecked)&&(e.nodeType===1||e.nodeType===11)&&!v.isXMLDoc(e)){Ot(e,o),r=Mt(e),i=Mt(o);for(s=0;r[s];++s)i[s]&&Ot(r[s],i[s])}if(t){At(e,o);if(n){r=Mt(e),i=Mt(o);for(s=0;r[s];++s)At(r[s],i[s])}}return r=i=null,o},clean:function(e,t,n,r){var s,o,u,a,f,l,c,h,p,d,m,g,y=t===i&&Ct,b=[];if(!t||typeof t.createDocumentFragment=="undefined")t=i;for(s=0;(u=e[s])!=null;s++){typeof u=="number"&&(u+="");if(!u)continue;if(typeof u=="string")if(!gt.test(u))u=t.createTextNode(u);else{y=y||lt(t),c=t.createElement("div"),y.appendChild(c),u=u.replace(dt,"<$1>"),a=(vt.exec(u)||["",""])[1].toLowerCase(),f=Nt[a]||Nt._default,l=f[0],c.innerHTML=f[1]+u+f[2];while(l--)c=c.lastChild;if(!v.support.tbody){h=mt.test(u),p=a==="table"&&!h?c.firstChild&&c.firstChild.childNodes:f[1]===""&&!h?c.childNodes:[];for(o=p.length-1;o>=0;--o)v.nodeName(p[o],"tbody")&&!p[o].childNodes.length&&p[o].parentNode.removeChild(p[o])}!v.support.leadingWhitespace&&pt.test(u)&&c.insertBefore(t.createTextNode(pt.exec(u)[0]),c.firstChild),u=c.childNodes,c.parentNode.removeChild(c)}u.nodeType?b.push(u):v.merge(b,u)}c&&(u=c=y=null);if(!v.support.appendChecked)for(s=0;(u=b[s])!=null;s++)v.nodeName(u,"input")?_t(u):typeof u.getElementsByTagName!="undefined"&&v.grep(u.getElementsByTagName("input"),_t);if(n){m=function(e){if(!e.type||xt.test(e.type))return r?r.push(e.parentNode?e.parentNode.removeChild(e):e):n.appendChild(e)};for(s=0;(u=b[s])!=null;s++)if(!v.nodeName(u,"script")||!m(u))n.appendChild(u),typeof u.getElementsByTagName!="undefined"&&(g=v.grep(v.merge([],u.getElementsByTagName("script")),m),b.splice.apply(b,[s+1,0].concat(g)),s+=g.length)}return b},cleanData:function(e,t){var n,r,i,s,o=0,u=v.expando,a=v.cache,f=v.support.deleteExpando,l=v.event.special;for(;(i=e[o])!=null;o++)if(t||v.acceptData(i)){r=i[u],n=r&&a[r];if(n){if(n.events)for(s in n.events)l[s]?v.event.remove(i,s):v.removeEvent(i,s,n.handle);a[r]&&(delete a[r],f?delete i[u]:i.removeAttribute?i.removeAttribute(u):i[u]=null,v.deletedIds.push(r))}}}}),function(){var e,t;v.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e=v.uaMatch(o.userAgent),t={},e.browser&&(t[e.browser]=!0,t.version=e.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),v.browser=t,v.sub=function(){function e(t,n){return new e.fn.init(t,n)}v.extend(!0,e,this),e.superclass=this,e.fn=e.prototype=this(),e.fn.constructor=e,e.sub=this.sub,e.fn.init=function(r,i){return i&&i instanceof v&&!(i instanceof e)&&(i=e(i)),v.fn.init.call(this,r,i,t)},e.fn.init.prototype=e.fn;var t=e(i);return e}}();var Dt,Pt,Ht,Bt=/alpha\([^)]*\)/i,jt=/opacity=([^)]*)/,Ft=/^(top|right|bottom|left)$/,It=/^(none|table(?!-c[ea]).+)/,qt=/^margin/,Rt=new RegExp("^("+m+")(.*)$","i"),Ut=new RegExp("^("+m+")(?!px)[a-z%]+$","i"),zt=new RegExp("^([-+])=("+m+")","i"),Wt={BODY:"block"},Xt={position:"absolute",visibility:"hidden",display:"block"},Vt={letterSpacing:0,fontWeight:400},$t=["Top","Right","Bottom","Left"],Jt=["Webkit","O","Moz","ms"],Kt=v.fn.toggle;v.fn.extend({css:function(e,n){return v.access(this,function(e,n,r){return r!==t?v.style(e,n,r):v.css(e,n)},e,n,arguments.length>1)},show:function(){return Yt(this,!0)},hide:function(){return Yt(this)},toggle:function(e,t){var n=typeof e=="boolean";return v.isFunction(e)&&v.isFunction(t)?Kt.apply(this,arguments):this.each(function(){(n?e:Gt(this))?v(this).show():v(this).hide()})}}),v.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Dt(e,"opacity");return n===""?"1":n}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":v.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(!e||e.nodeType===3||e.nodeType===8||!e.style)return;var s,o,u,a=v.camelCase(n),f=e.style;n=v.cssProps[a]||(v.cssProps[a]=Qt(f,a)),u=v.cssHooks[n]||v.cssHooks[a];if(r===t)return u&&"get"in u&&(s=u.get(e,!1,i))!==t?s:f[n];o=typeof r,o==="string"&&(s=zt.exec(r))&&(r=(s[1]+1)*s[2]+parseFloat(v.css(e,n)),o="number");if(r==null||o==="number"&&isNaN(r))return;o==="number"&&!v.cssNumber[a]&&(r+="px");if(!u||!("set"in u)||(r=u.set(e,r,i))!==t)try{f[n]=r}catch(l){}},css:function(e,n,r,i){var s,o,u,a=v.camelCase(n);return n=v.cssProps[a]||(v.cssProps[a]=Qt(e.style,a)),u=v.cssHooks[n]||v.cssHooks[a],u&&"get"in u&&(s=u.get(e,!0,i)),s===t&&(s=Dt(e,n)),s==="normal"&&n in Vt&&(s=Vt[n]),r||i!==t?(o=parseFloat(s),r||v.isNumeric(o)?o||0:s):s},swap:function(e,t,n){var r,i,s={};for(i in t)s[i]=e.style[i],e.style[i]=t[i];r=n.call(e);for(i in t)e.style[i]=s[i];return r}}),e.getComputedStyle?Dt=function(t,n){var r,i,s,o,u=e.getComputedStyle(t,null),a=t.style;return u&&(r=u.getPropertyValue(n)||u[n],r===""&&!v.contains(t.ownerDocument,t)&&(r=v.style(t,n)),Ut.test(r)&&qt.test(n)&&(i=a.width,s=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=r,r=u.width,a.width=i,a.minWidth=s,a.maxWidth=o)),r}:i.documentElement.currentStyle&&(Dt=function(e,t){var n,r,i=e.currentStyle&&e.currentStyle[t],s=e.style;return i==null&&s&&s[t]&&(i=s[t]),Ut.test(i)&&!Ft.test(t)&&(n=s.left,r=e.runtimeStyle&&e.runtimeStyle.left,r&&(e.runtimeStyle.left=e.currentStyle.left),s.left=t==="fontSize"?"1em":i,i=s.pixelLeft+"px",s.left=n,r&&(e.runtimeStyle.left=r)),i===""?"auto":i}),v.each(["height","width"],function(e,t){v.cssHooks[t]={get:function(e,n,r){if(n)return e.offsetWidth===0&&It.test(Dt(e,"display"))?v.swap(e,Xt,function(){return tn(e,t,r)}):tn(e,t,r)},set:function(e,n,r){return Zt(e,n,r?en(e,t,r,v.support.boxSizing&&v.css(e,"boxSizing")==="border-box"):0)}}}),v.support.opacity||(v.cssHooks.opacity={get:function(e,t){return jt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=v.isNumeric(t)?"alpha(opacity="+t*100+")":"",s=r&&r.filter||n.filter||"";n.zoom=1;if(t>=1&&v.trim(s.replace(Bt,""))===""&&n.removeAttribute){n.removeAttribute("filter");if(r&&!r.filter)return}n.filter=Bt.test(s)?s.replace(Bt,i):s+" "+i}}),v(function(){v.support.reliableMarginRight||(v.cssHooks.marginRight={get:function(e,t){return v.swap(e,{display:"inline-block"},function(){if(t)return Dt(e,"marginRight")})}}),!v.support.pixelPosition&&v.fn.position&&v.each(["top","left"],function(e,t){v.cssHooks[t]={get:function(e,n){if(n){var r=Dt(e,t);return Ut.test(r)?v(e).position()[t]+"px":r}}}})}),v.expr&&v.expr.filters&&(v.expr.filters.hidden=function(e){return e.offsetWidth===0&&e.offsetHeight===0||!v.support.reliableHiddenOffsets&&(e.style&&e.style.display||Dt(e,"display"))==="none"},v.expr.filters.visible=function(e){return!v.expr.filters.hidden(e)}),v.each({margin:"",padding:"",border:"Width"},function(e,t){v.cssHooks[e+t]={expand:function(n){var r,i=typeof n=="string"?n.split(" "):[n],s={};for(r=0;r<4;r++)s[e+$t[r]+t]=i[r]||i[r-2]||i[0];return s}},qt.test(e)||(v.cssHooks[e+t].set=Zt)});var rn=/%20/g,sn=/\[\]$/,on=/\r?\n/g,un=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,an=/^(?:select|textarea)/i;v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?v.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||an.test(this.nodeName)||un.test(this.type))}).map(function(e,t){var n=v(this).val();return n==null?null:v.isArray(n)?v.map(n,function(e,n){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),v.param=function(e,n){var r,i=[],s=function(e,t){t=v.isFunction(t)?t():t==null?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};n===t&&(n=v.ajaxSettings&&v.ajaxSettings.traditional);if(v.isArray(e)||e.jquery&&!v.isPlainObject(e))v.each(e,function(){s(this.name,this.value)});else for(r in e)fn(r,e[r],n,s);return i.join("&").replace(rn,"+")};var ln,cn,hn=/#.*$/,pn=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,dn=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,vn=/^(?:GET|HEAD)$/,mn=/^\/\//,gn=/\?/,yn=/)<[^<]*)*<\/script>/gi,bn=/([?&])_=[^&]*/,wn=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,En=v.fn.load,Sn={},xn={},Tn=["*/"]+["*"];try{cn=s.href}catch(Nn){cn=i.createElement("a"),cn.href="",cn=cn.href}ln=wn.exec(cn.toLowerCase())||[],v.fn.load=function(e,n,r){if(typeof e!="string"&&En)return En.apply(this,arguments);if(!this.length)return this;var i,s,o,u=this,a=e.indexOf(" ");return a>=0&&(i=e.slice(a,e.length),e=e.slice(0,a)),v.isFunction(n)?(r=n,n=t):n&&typeof n=="object"&&(s="POST"),v.ajax({url:e,type:s,dataType:"html",data:n,complete:function(e,t){r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u.html(i?v("
").append(e.replace(yn,"")).find(i):e)}),this},v.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,t){v.fn[t]=function(e){return this.on(t,e)}}),v.each(["get","post"],function(e,n){v[n]=function(e,r,i,s){return v.isFunction(r)&&(s=s||i,i=r,r=t),v.ajax({type:n,url:e,data:r,success:i,dataType:s})}}),v.extend({getScript:function(e,n){return v.get(e,t,n,"script")},getJSON:function(e,t,n){return v.get(e,t,n,"json")},ajaxSetup:function(e,t){return t?Ln(e,v.ajaxSettings):(t=e,e=v.ajaxSettings),Ln(e,t),e},ajaxSettings:{url:cn,isLocal:dn.test(ln[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":Tn},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":v.parseJSON,"text xml":v.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:Cn(Sn),ajaxTransport:Cn(xn),ajax:function(e,n){function T(e,n,s,a){var l,y,b,w,S,T=n;if(E===2)return;E=2,u&&clearTimeout(u),o=t,i=a||"",x.readyState=e>0?4:0,s&&(w=An(c,x,s));if(e>=200&&e<300||e===304)c.ifModified&&(S=x.getResponseHeader("Last-Modified"),S&&(v.lastModified[r]=S),S=x.getResponseHeader("Etag"),S&&(v.etag[r]=S)),e===304?(T="notmodified",l=!0):(l=On(c,w),T=l.state,y=l.data,b=l.error,l=!b);else{b=T;if(!T||e)T="error",e<0&&(e=0)}x.status=e,x.statusText=(n||T)+"",l?d.resolveWith(h,[y,T,x]):d.rejectWith(h,[x,T,b]),x.statusCode(g),g=t,f&&p.trigger("ajax"+(l?"Success":"Error"),[x,c,l?y:b]),m.fireWith(h,[x,T]),f&&(p.trigger("ajaxComplete",[x,c]),--v.active||v.event.trigger("ajaxStop"))}typeof e=="object"&&(n=e,e=t),n=n||{};var r,i,s,o,u,a,f,l,c=v.ajaxSetup({},n),h=c.context||c,p=h!==c&&(h.nodeType||h instanceof v)?v(h):v.event,d=v.Deferred(),m=v.Callbacks("once memory"),g=c.statusCode||{},b={},w={},E=0,S="canceled",x={readyState:0,setRequestHeader:function(e,t){if(!E){var n=e.toLowerCase();e=w[n]=w[n]||e,b[e]=t}return this},getAllResponseHeaders:function(){return E===2?i:null},getResponseHeader:function(e){var n;if(E===2){if(!s){s={};while(n=pn.exec(i))s[n[1].toLowerCase()]=n[2]}n=s[e.toLowerCase()]}return n===t?null:n},overrideMimeType:function(e){return E||(c.mimeType=e),this},abort:function(e){return e=e||S,o&&o.abort(e),T(0,e),this}};d.promise(x),x.success=x.done,x.error=x.fail,x.complete=m.add,x.statusCode=function(e){if(e){var t;if(E<2)for(t in e)g[t]=[g[t],e[t]];else t=e[x.status],x.always(t)}return this},c.url=((e||c.url)+"").replace(hn,"").replace(mn,ln[1]+"//"),c.dataTypes=v.trim(c.dataType||"*").toLowerCase().split(y),c.crossDomain==null&&(a=wn.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===ln[1]&&a[2]===ln[2]&&(a[3]||(a[1]==="http:"?80:443))==(ln[3]||(ln[1]==="http:"?80:443)))),c.data&&c.processData&&typeof c.data!="string"&&(c.data=v.param(c.data,c.traditional)),kn(Sn,c,n,x);if(E===2)return x;f=c.global,c.type=c.type.toUpperCase(),c.hasContent=!vn.test(c.type),f&&v.active++===0&&v.event.trigger("ajaxStart");if(!c.hasContent){c.data&&(c.url+=(gn.test(c.url)?"&":"?")+c.data,delete c.data),r=c.url;if(c.cache===!1){var N=v.now(),C=c.url.replace(bn,"$1_="+N);c.url=C+(C===c.url?(gn.test(c.url)?"&":"?")+"_="+N:"")}}(c.data&&c.hasContent&&c.contentType!==!1||n.contentType)&&x.setRequestHeader("Content-Type",c.contentType),c.ifModified&&(r=r||c.url,v.lastModified[r]&&x.setRequestHeader("If-Modified-Since",v.lastModified[r]),v.etag[r]&&x.setRequestHeader("If-None-Match",v.etag[r])),x.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+(c.dataTypes[0]!=="*"?", "+Tn+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)x.setRequestHeader(l,c.headers[l]);if(!c.beforeSend||c.beforeSend.call(h,x,c)!==!1&&E!==2){S="abort";for(l in{success:1,error:1,complete:1})x[l](c[l]);o=kn(xn,c,n,x);if(!o)T(-1,"No Transport");else{x.readyState=1,f&&p.trigger("ajaxSend",[x,c]),c.async&&c.timeout>0&&(u=setTimeout(function(){x.abort("timeout")},c.timeout));try{E=1,o.send(b,T)}catch(k){if(!(E<2))throw k;T(-1,k)}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var Mn=[],_n=/\?/,Dn=/(=)\?(?=&|$)|\?\?/,Pn=v.now();v.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mn.pop()||v.expando+"_"+Pn++;return this[e]=!0,e}}),v.ajaxPrefilter("json jsonp",function(n,r,i){var s,o,u,a=n.data,f=n.url,l=n.jsonp!==!1,c=l&&Dn.test(f),h=l&&!c&&typeof a=="string"&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Dn.test(a);if(n.dataTypes[0]==="jsonp"||c||h)return s=n.jsonpCallback=v.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,o=e[s],c?n.url=f.replace(Dn,"$1"+s):h?n.data=a.replace(Dn,"$1"+s):l&&(n.url+=(_n.test(f)?"&":"?")+n.jsonp+"="+s),n.converters["script json"]=function(){return u||v.error(s+" was not called"),u[0]},n.dataTypes[0]="json",e[s]=function(){u=arguments},i.always(function(){e[s]=o,n[s]&&(n.jsonpCallback=r.jsonpCallback,Mn.push(s)),u&&v.isFunction(o)&&o(u[0]),u=o=t}),"script"}),v.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(e){return v.globalEval(e),e}}}),v.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),v.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=i.head||i.getElementsByTagName("head")[0]||i.documentElement;return{send:function(s,o){n=i.createElement("script"),n.async="async",e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,i){if(i||!n.readyState||/loaded|complete/.test(n.readyState))n.onload=n.onreadystatechange=null,r&&n.parentNode&&r.removeChild(n),n=t,i||o(200,"success")},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(0,1)}}}});var Hn,Bn=e.ActiveXObject?function(){for(var e in Hn)Hn[e](0,1)}:!1,jn=0;v.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&Fn()||In()}:Fn,function(e){v.extend(v.support,{ajax:!!e,cors:!!e&&"withCredentials"in e})}(v.ajaxSettings.xhr()),v.support.ajax&&v.ajaxTransport(function(n){if(!n.crossDomain||v.support.cors){var r;return{send:function(i,s){var o,u,a=n.xhr();n.username?a.open(n.type,n.url,n.async,n.username,n.password):a.open(n.type,n.url,n.async);if(n.xhrFields)for(u in n.xhrFields)a[u]=n.xhrFields[u];n.mimeType&&a.overrideMimeType&&a.overrideMimeType(n.mimeType),!n.crossDomain&&!i["X-Requested-With"]&&(i["X-Requested-With"]="XMLHttpRequest");try{for(u in i)a.setRequestHeader(u,i[u])}catch(f){}a.send(n.hasContent&&n.data||null),r=function(e,i){var u,f,l,c,h;try{if(r&&(i||a.readyState===4)){r=t,o&&(a.onreadystatechange=v.noop,Bn&&delete Hn[o]);if(i)a.readyState!==4&&a.abort();else{u=a.status,l=a.getAllResponseHeaders(),c={},h=a.responseXML,h&&h.documentElement&&(c.xml=h);try{c.text=a.responseText}catch(p){}try{f=a.statusText}catch(p){f=""}!u&&n.isLocal&&!n.crossDomain?u=c.text?200:404:u===1223&&(u=204)}}}catch(d){i||s(-1,d)}c&&s(u,f,c,l)},n.async?a.readyState===4?setTimeout(r,0):(o=++jn,Bn&&(Hn||(Hn={},v(e).unload(Bn)),Hn[o]=r),a.onreadystatechange=r):r()},abort:function(){r&&r(0,1)}}}});var qn,Rn,Un=/^(?:toggle|show|hide)$/,zn=new RegExp("^(?:([-+])=|)("+m+")([a-z%]*)$","i"),Wn=/queueHooks$/,Xn=[Gn],Vn={"*":[function(e,t){var n,r,i=this.createTween(e,t),s=zn.exec(t),o=i.cur(),u=+o||0,a=1,f=20;if(s){n=+s[2],r=s[3]||(v.cssNumber[e]?"":"px");if(r!=="px"&&u){u=v.css(i.elem,e,!0)||n||1;do a=a||".5",u/=a,v.style(i.elem,e,u+r);while(a!==(a=i.cur()/o)&&a!==1&&--f)}i.unit=r,i.start=u,i.end=s[1]?u+(s[1]+1)*n:n}return i}]};v.Animation=v.extend(Kn,{tweener:function(e,t){v.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;r-1,f={},l={},c,h;a?(l=i.position(),c=l.top,h=l.left):(c=parseFloat(o)||0,h=parseFloat(u)||0),v.isFunction(t)&&(t=t.call(e,n,s)),t.top!=null&&(f.top=t.top-s.top+c),t.left!=null&&(f.left=t.left-s.left+h),"using"in t?t.using.call(e,f):i.css(f)}},v.fn.extend({position:function(){if(!this[0])return;var e=this[0],t=this.offsetParent(),n=this.offset(),r=er.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(v.css(e,"marginTop"))||0,n.left-=parseFloat(v.css(e,"marginLeft"))||0,r.top+=parseFloat(v.css(t[0],"borderTopWidth"))||0,r.left+=parseFloat(v.css(t[0],"borderLeftWidth"))||0,{top:n.top-r.top,left:n.left-r.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||i.body;while(e&&!er.test(e.nodeName)&&v.css(e,"position")==="static")e=e.offsetParent;return e||i.body})}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);v.fn[e]=function(i){return v.access(this,function(e,i,s){var o=tr(e);if(s===t)return o?n in o?o[n]:o.document.documentElement[i]:e[i];o?o.scrollTo(r?v(o).scrollLeft():s,r?s:v(o).scrollTop()):e[i]=s},e,i,arguments.length,null)}}),v.each({Height:"height",Width:"width"},function(e,n){v.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){v.fn[i]=function(i,s){var o=arguments.length&&(r||typeof i!="boolean"),u=r||(i===!0||s===!0?"margin":"border");return v.access(this,function(n,r,i){var s;return v.isWindow(n)?n.document.documentElement["client"+e]:n.nodeType===9?(s=n.documentElement,Math.max(n.body["scroll"+e],s["scroll"+e],n.body["offset"+e],s["offset"+e],s["client"+e])):i===t?v.css(n,r,i,u):v.style(n,r,i,u)},n,o?i:t,o,null)}})}),e.jQuery=e.$=v,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return v})})(window); \ No newline at end of file Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/minus.png and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/minus.png differ Binary files /tmp/tmpZyBIrz/nbb6lYtg2p/django-filter-0.11.0/docs/_build/html/_static/plus.png and /tmp/tmpZyBIrz/4NOw_DrXEb/django-filter-0.13.0/docs/_build/html/_static/plus.png differ diff -Nru django-filter-0.11.0/docs/_build/html/_static/pygments.css django-filter-0.13.0/docs/_build/html/_static/pygments.css --- django-filter-0.11.0/docs/_build/html/_static/pygments.css 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_static/pygments.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -.highlight .hll { background-color: #ffffcc } -.highlight { background: #eeffcc; } -.highlight .c { color: #408090; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #007020; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #007020 } /* Comment.Preproc */ -.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #333333 } /* Generic.Output */ -.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0044DD } /* Generic.Traceback */ -.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #007020 } /* Keyword.Pseudo */ -.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #902000 } /* Keyword.Type */ -.highlight .m { color: #208050 } /* Literal.Number */ -.highlight .s { color: #4070a0 } /* Literal.String */ -.highlight .na { color: #4070a0 } /* Name.Attribute */ -.highlight .nb { color: #007020 } /* Name.Builtin */ -.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ -.highlight .no { color: #60add5 } /* Name.Constant */ -.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ -.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #007020 } /* Name.Exception */ -.highlight .nf { color: #06287e } /* Name.Function */ -.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ -.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #bb60d5 } /* Name.Variable */ -.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mb { color: #208050 } /* Literal.Number.Bin */ -.highlight .mf { color: #208050 } /* Literal.Number.Float */ -.highlight .mh { color: #208050 } /* Literal.Number.Hex */ -.highlight .mi { color: #208050 } /* Literal.Number.Integer */ -.highlight .mo { color: #208050 } /* Literal.Number.Oct */ -.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ -.highlight .sc { color: #4070a0 } /* Literal.String.Char */ -.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #4070a0 } /* Literal.String.Double */ -.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ -.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ -.highlight .sx { color: #c65d09 } /* Literal.String.Other */ -.highlight .sr { color: #235388 } /* Literal.String.Regex */ -.highlight .s1 { color: #4070a0 } /* Literal.String.Single */ -.highlight .ss { color: #517918 } /* Literal.String.Symbol */ -.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ -.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ -.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ -.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/_static/searchtools.js django-filter-0.13.0/docs/_build/html/_static/searchtools.js --- django-filter-0.11.0/docs/_build/html/_static/searchtools.js 2014-11-28 11:13:33.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/_static/searchtools.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,622 +0,0 @@ -/* - * searchtools.js_t - * ~~~~~~~~~~~~~~~~ - * - * Sphinx JavaScript utilties for the full-text search. - * - * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. - * :license: BSD, see LICENSE for details. - * - */ - - -/** - * Porter Stemmer - */ -var Stemmer = function() { - - var step2list = { - ational: 'ate', - tional: 'tion', - enci: 'ence', - anci: 'ance', - izer: 'ize', - bli: 'ble', - alli: 'al', - entli: 'ent', - eli: 'e', - ousli: 'ous', - ization: 'ize', - ation: 'ate', - ator: 'ate', - alism: 'al', - iveness: 'ive', - fulness: 'ful', - ousness: 'ous', - aliti: 'al', - iviti: 'ive', - biliti: 'ble', - logi: 'log' - }; - - var step3list = { - icate: 'ic', - ative: '', - alize: 'al', - iciti: 'ic', - ical: 'ic', - ful: '', - ness: '' - }; - - var c = "[^aeiou]"; // consonant - var v = "[aeiouy]"; // vowel - var C = c + "[^aeiouy]*"; // consonant sequence - var V = v + "[aeiou]*"; // vowel sequence - - var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 - var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 - var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 - var s_v = "^(" + C + ")?" + v; // vowel in stem - - this.stemWord = function (w) { - var stem; - var suffix; - var firstch; - var origword = w; - - if (w.length < 3) - return w; - - var re; - var re2; - var re3; - var re4; - - firstch = w.substr(0,1); - if (firstch == "y") - w = firstch.toUpperCase() + w.substr(1); - - // Step 1a - re = /^(.+?)(ss|i)es$/; - re2 = /^(.+?)([^s])s$/; - - if (re.test(w)) - w = w.replace(re,"$1$2"); - else if (re2.test(w)) - w = w.replace(re2,"$1$2"); - - // Step 1b - re = /^(.+?)eed$/; - re2 = /^(.+?)(ed|ing)$/; - if (re.test(w)) { - var fp = re.exec(w); - re = new RegExp(mgr0); - if (re.test(fp[1])) { - re = /.$/; - w = w.replace(re,""); - } - } - else if (re2.test(w)) { - var fp = re2.exec(w); - stem = fp[1]; - re2 = new RegExp(s_v); - if (re2.test(stem)) { - w = stem; - re2 = /(at|bl|iz)$/; - re3 = new RegExp("([^aeiouylsz])\\1$"); - re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); - if (re2.test(w)) - w = w + "e"; - else if (re3.test(w)) { - re = /.$/; - w = w.replace(re,""); - } - else if (re4.test(w)) - w = w + "e"; - } - } - - // Step 1c - re = /^(.+?)y$/; - if (re.test(w)) { - var fp = re.exec(w); - stem = fp[1]; - re = new RegExp(s_v); - if (re.test(stem)) - w = stem + "i"; - } - - // Step 2 - re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; - if (re.test(w)) { - var fp = re.exec(w); - stem = fp[1]; - suffix = fp[2]; - re = new RegExp(mgr0); - if (re.test(stem)) - w = stem + step2list[suffix]; - } - - // Step 3 - re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; - if (re.test(w)) { - var fp = re.exec(w); - stem = fp[1]; - suffix = fp[2]; - re = new RegExp(mgr0); - if (re.test(stem)) - w = stem + step3list[suffix]; - } - - // Step 4 - re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; - re2 = /^(.+?)(s|t)(ion)$/; - if (re.test(w)) { - var fp = re.exec(w); - stem = fp[1]; - re = new RegExp(mgr1); - if (re.test(stem)) - w = stem; - } - else if (re2.test(w)) { - var fp = re2.exec(w); - stem = fp[1] + fp[2]; - re2 = new RegExp(mgr1); - if (re2.test(stem)) - w = stem; - } - - // Step 5 - re = /^(.+?)e$/; - if (re.test(w)) { - var fp = re.exec(w); - stem = fp[1]; - re = new RegExp(mgr1); - re2 = new RegExp(meq1); - re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); - if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) - w = stem; - } - re = /ll$/; - re2 = new RegExp(mgr1); - if (re.test(w) && re2.test(w)) { - re = /.$/; - w = w.replace(re,""); - } - - // and turn initial Y back to y - if (firstch == "y") - w = firstch.toLowerCase() + w.substr(1); - return w; - } -} - - - -/** - * Simple result scoring code. - */ -var Scorer = { - // Implement the following function to further tweak the score for each result - // The function takes a result array [filename, title, anchor, descr, score] - // and returns the new score. - /* - score: function(result) { - return result[4]; - }, - */ - - // query matches the full name of an object - objNameMatch: 11, - // or matches in the last dotted part of the object name - objPartialMatch: 6, - // Additive scores depending on the priority of the object - objPrio: {0: 15, // used to be importantResults - 1: 5, // used to be objectResults - 2: -5}, // used to be unimportantResults - // Used when the priority is not in the mapping. - objPrioDefault: 0, - - // query found in title - title: 15, - // query found in terms - term: 5 -}; - - -/** - * Search Module - */ -var Search = { - - _index : null, - _queued_query : null, - _pulse_status : -1, - - init : function() { - var params = $.getQueryParameters(); - if (params.q) { - var query = params.q[0]; - $('input[name="q"]')[0].value = query; - this.performSearch(query); - } - }, - - loadIndex : function(url) { - $.ajax({type: "GET", url: url, data: null, - dataType: "script", cache: true, - complete: function(jqxhr, textstatus) { - if (textstatus != "success") { - document.getElementById("searchindexloader").src = url; - } - }}); - }, - - setIndex : function(index) { - var q; - this._index = index; - if ((q = this._queued_query) !== null) { - this._queued_query = null; - Search.query(q); - } - }, - - hasIndex : function() { - return this._index !== null; - }, - - deferQuery : function(query) { - this._queued_query = query; - }, - - stopPulse : function() { - this._pulse_status = 0; - }, - - startPulse : function() { - if (this._pulse_status >= 0) - return; - function pulse() { - var i; - Search._pulse_status = (Search._pulse_status + 1) % 4; - var dotString = ''; - for (i = 0; i < Search._pulse_status; i++) - dotString += '.'; - Search.dots.text(dotString); - if (Search._pulse_status > -1) - window.setTimeout(pulse, 500); - } - pulse(); - }, - - /** - * perform a search for something (or wait until index is loaded) - */ - performSearch : function(query) { - // create the required interface elements - this.out = $('#search-results'); - this.title = $('

' + _('Searching') + '

').appendTo(this.out); - this.dots = $('').appendTo(this.title); - this.status = $('

').appendTo(this.out); - this.output = $('
'); - } - // Prettify the comment rating. - comment.pretty_rating = comment.rating + ' point' + - (comment.rating == 1 ? '' : 's'); - // Make a class (for displaying not yet moderated comments differently) - comment.css_class = comment.displayed ? '' : ' moderate'; - // Create a div for this comment. - var context = $.extend({}, opts, comment); - var div = $(renderTemplate(commentTemplate, context)); - - // If the user has voted on this comment, highlight the correct arrow. - if (comment.vote) { - var direction = (comment.vote == 1) ? 'u' : 'd'; - div.find('#' + direction + 'v' + comment.id).hide(); - div.find('#' + direction + 'u' + comment.id).show(); - } - - if (opts.moderator || comment.text != '[deleted]') { - div.find('a.reply').show(); - if (comment.proposal_diff) - div.find('#sp' + comment.id).show(); - if (opts.moderator && !comment.displayed) - div.find('#cm' + comment.id).show(); - if (opts.moderator || (opts.username == comment.username)) - div.find('#dc' + comment.id).show(); - } - return div; - } - - /** - * A simple template renderer. Placeholders such as <%id%> are replaced - * by context['id'] with items being escaped. Placeholders such as <#id#> - * are not escaped. - */ - function renderTemplate(template, context) { - var esc = $(document.createElement('div')); - - function handle(ph, escape) { - var cur = context; - $.each(ph.split('.'), function() { - cur = cur[this]; - }); - return escape ? esc.text(cur || "").html() : cur; - } - - return template.replace(/<([%#])([\w\.]*)\1>/g, function() { - return handle(arguments[2], arguments[1] == '%' ? true : false); - }); - } - - /** Flash an error message briefly. */ - function showError(message) { - $(document.createElement('div')).attr({'class': 'popup-error'}) - .append($(document.createElement('div')) - .attr({'class': 'error-message'}).text(message)) - .appendTo('body') - .fadeIn("slow") - .delay(2000) - .fadeOut("slow"); - } - - /** Add a link the user uses to open the comments popup. */ - $.fn.comment = function() { - return this.each(function() { - var id = $(this).attr('id').substring(1); - var count = COMMENT_METADATA[id]; - var title = count + ' comment' + (count == 1 ? '' : 's'); - var image = count > 0 ? opts.commentBrightImage : opts.commentImage; - var addcls = count == 0 ? ' nocomment' : ''; - $(this) - .append( - $(document.createElement('a')).attr({ - href: '#', - 'class': 'sphinx-comment-open' + addcls, - id: 'ao' + id - }) - .append($(document.createElement('img')).attr({ - src: image, - alt: 'comment', - title: title - })) - .click(function(event) { - event.preventDefault(); - show($(this).attr('id').substring(2)); - }) - ) - .append( - $(document.createElement('a')).attr({ - href: '#', - 'class': 'sphinx-comment-close hidden', - id: 'ah' + id - }) - .append($(document.createElement('img')).attr({ - src: opts.closeCommentImage, - alt: 'close', - title: 'close' - })) - .click(function(event) { - event.preventDefault(); - hide($(this).attr('id').substring(2)); - }) - ); - }); - }; - - var opts = { - processVoteURL: '/_process_vote', - addCommentURL: '/_add_comment', - getCommentsURL: '/_get_comments', - acceptCommentURL: '/_accept_comment', - deleteCommentURL: '/_delete_comment', - commentImage: '/static/_static/comment.png', - closeCommentImage: '/static/_static/comment-close.png', - loadingImage: '/static/_static/ajax-loader.gif', - commentBrightImage: '/static/_static/comment-bright.png', - upArrow: '/static/_static/up.png', - downArrow: '/static/_static/down.png', - upArrowPressed: '/static/_static/up-pressed.png', - downArrowPressed: '/static/_static/down-pressed.png', - voting: false, - moderator: false - }; - - if (typeof COMMENT_OPTIONS != "undefined") { - opts = jQuery.extend(opts, COMMENT_OPTIONS); - } - - var popupTemplate = '\ -
\ -

\ - Sort by:\ - best rated\ - newest\ - oldest\ -

\ -
Comments
\ -
\ - loading comments...
\ -
    \ -
    \ -

    Add a comment\ - (markup):

    \ -
    \ - reStructured text markup: *emph*, **strong**, \ - ``code``, \ - code blocks: :: and an indented block after blank line
    \ -
    \ - \ -

    \ - \ - Propose a change ▹\ - \ - \ - Propose a change ▿\ - \ -

    \ - \ - \ - \ - \ - \ -
    \ -
    '; - - var commentTemplate = '\ -
    \ -
    \ -
    \ - \ - \ - \ - \ - \ - \ -
    \ -
    \ - \ - \ - \ - \ - \ - \ -
    \ -
    \ -
    \ -

    \ - <%username%>\ - <%pretty_rating%>\ - <%time.delta%>\ -

    \ -
    <#text#>
    \ -

    \ - \ - reply ▿\ - proposal ▹\ - proposal ▿\ - \ - \ -

    \ -
    \
    -<#proposal_diff#>\
    -        
    \ -
      \ -
      \ -
      \ -
      \ - '; - - var replyTemplate = '\ -
    • \ -
      \ -
      \ - \ - \ - \ - \ - \ - \ -
      \ -
    • '; - - $(document).ready(function() { - init(); - }); -})(jQuery); - -$(document).ready(function() { - // add comment anchors for all paragraphs that are commentable - $('.sphinx-has-comment').comment(); - - // highlight search words in search results - $("div.context").each(function() { - var params = $.getQueryParameters(); - var terms = (params.q) ? params.q[0].split(/\s+/) : []; - var result = $(this); - $.each(terms, function() { - result.highlightText(this.toLowerCase(), 'highlighted'); - }); - }); - - // directly open comment window if requested - var anchor = document.location.hash; - if (anchor.substring(0, 9) == '#comment-') { - $('#ao' + anchor.substring(9)).click(); - document.location.hash = '#s' + anchor.substring(9); - } -}); diff -Nru django-filter-0.11.0/docs/_build/html/tests.html django-filter-0.13.0/docs/_build/html/tests.html --- django-filter-0.11.0/docs/_build/html/tests.html 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/tests.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ - - - - - - - - Running the django-filter tests — django-filter 0.9.0 documentation - - - - - - - - - - - - - - -
      -
      -
      -
      - -
      -

      Running the django-filter tests

      -

      The easiest way to run the django-filter tests is to check out the source -code into a virtualenv, where you can install the test dependencies. -django-filter uses a custom test runner to locate all of the tests, so a -wrapper script is available to set up and run the test suite.

      -
      -

      Note

      -

      The following assumes you have virtualenv and git installed.

      -
      -
      -

      Set up a virtualenv for the test suite

      -

      Run the following to create a new virtualenv to run the test suite in:

      -
      virtualenv django-filter-tests
      -cd django-filter-tests
      -. bin/activate
      -
      -
      -
      -
      -

      Get a copy of django-filter

      -

      Get the django-filter source code using the following command:

      -
      git clone https://github.com/alex/django-filter.git
      -
      -
      -

      Switch to the django-filter directory:

      -
      cd django-filter
      -
      -
      -
      -
      -

      Install the test dependencies

      -

      Run the following to install the test dependencies within the -virutalenv:

      -
      pip install -r requirements/test.txt
      -
      -
      -

      Run the django-filter tests:

      -
      python runtests.py
      -
      -
      -
      -
      - - -
      -
      -
      -
      -
      -

      Table Of Contents

      - - -

      Previous topic

      -

      Widget Reference

      -

      This Page

      - - - -
      -
      -
      -
      - - - - \ No newline at end of file diff -Nru django-filter-0.11.0/docs/_build/html/usage.html django-filter-0.13.0/docs/_build/html/usage.html --- django-filter-0.11.0/docs/_build/html/usage.html 2014-11-28 11:13:32.000000000 +0000 +++ django-filter-0.13.0/docs/_build/html/usage.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,396 +0,0 @@ - - - - - - - - Using django-filter — django-filter 0.9.0 documentation - - - - - - - - - - - - - - - -
      -
      -
      -
      - -
      -

      Using django-filter

      -

      Django-filter provides a simple way to filter down a queryset based on -parameters a user provides. Say we have a Product model and we want to let -our users filter which products they see on a list page.

      -
      -

      The model

      -

      Let’s start with our model:

      -
      from django.db import models
      -
      -class Product(models.Model):
      -    name = models.CharField(max_length=255)
      -    price = models.DecimalField()
      -    description = models.TextField()
      -    release_date = models.DateField()
      -    manufacturer = models.ForeignKey(Manufacturer)
      -
      -
      -
      -
      -

      The filter

      -

      We have a number of fields and we want to let our users filter based on the -price or the release_date. We create a FilterSet for this:

      -
      import django_filters
      -
      -class ProductFilter(django_filters.FilterSet):
      -    class Meta:
      -        model = Product
      -        fields = ['price', 'release_date']
      -
      -
      -

      As you can see this uses a very similar API to Django’s ModelForm. Just -like with a ModelForm we can also override filters, or add new ones using a -declarative syntax:

      -
      import django_filters
      -
      -class ProductFilter(django_filters.FilterSet):
      -    price = django_filters.NumberFilter(lookup_type='lt')
      -    class Meta:
      -        model = Product
      -        fields = ['price', 'release_date']
      -
      -
      -

      Filters take a lookup_type argument which specifies what lookup type to -use with Django’s ORM. So here when a user entered a price it would show all -Products with a price less than that.

      -

      It’s quite common to forget to set lookup type for `CharField`s/`TextField`s -and wonder why search for “foo” doesn’t return result for “foobar”. It’s because -default lookup type is exact text, but you probably want `icontains` lookup -field.

      -

      The FilterSet Meta class fields can additionally be set using a Dictionary to -specify multiple lookup_type filters without significant code duplication:

      -
      import django_filters
      -
      -class ProductFilter(django_filters.FilterSet):
      -    class Meta:
      -        model = Product
      -        fields = {'price': ['lt', 'gt'],
      -                  'release_date': ['exact'],
      -                 }
      -
      -
      -

      The above would generate ‘price__lt’, ‘price__gt’ and ‘release_date’ filters. -The filter lookup type keyword ‘exact’ is the default and therefore never added -to a filter name.

      -

      Items in the fields sequence in the Meta class may include -“relationship paths” using Django’s __ syntax to filter on fields on a -related model:

      -
      class ProductFilter(django_filters.FilterSet):
      -    class Meta:
      -        model = Product
      -        fields = ['manufacturer__country']
      -
      -
      -

      Filters also take any arbitrary keyword arguments which get passed onto the -django.forms.Field initializer. These extra keyword arguments get stored -in Filter.extra, so it’s possible to override the initializer of a -FilterSet to add extra ones:

      -
      class ProductFilter(django_filters.FilterSet):
      -    class Meta:
      -        model = Product
      -        fields = ['manufacturer']
      -
      -    def __init__(self, *args, **kwargs):
      -        super(ProductFilter, self).__init__(*args, **kwargs)
      -        self.filters['manufacturer'].extra.update(
      -            {'empty_label': 'All Manufacturers'})
      -
      -
      -

      Like django.contrib.admin.ModelAdmin, it is possible to override -default filters for all the models fields of the same kind using -filter_overrides:

      -
      class ProductFilter(django_filters.FilterSet):
      -    filter_overrides = {
      -        models.CharField: {
      -            'filter_class': django_filters.CharFilter,
      -            'extra': lambda f: {
      -                'lookup_type': 'icontains',
      -            }
      -        }
      -    }
      -
      -    class Meta:
      -        model = Product
      -        fields = ['name']
      -
      -
      -
      -
      -

      The view

      -

      Now we need to write a view:

      -
      def product_list(request):
      -    f = ProductFilter(request.GET, queryset=Product.objects.all())
      -    return render_to_response('my_app/template.html', {'filter': f})
      -
      -
      -

      If a queryset argument isn’t provided then all the items in the default manager -of the model will be used.

      -

      If you want to access the filtered objects in your views, for example if you -want to paginate them, you can do that. They are in f.qs

      -
      -
      -

      The URL conf

      -

      We need a URL pattern to call the view:

      -
      url(r'^list$', views.product_list)
      -
      -
      -
      -
      -

      The template

      -

      And lastly we need a template:

      -
      {% extends "base.html" %}
      -
      -{% block content %}
      -    <form action="" method="get">
      -        {{ filter.form.as_p }}
      -        <input type="submit" />
      -    </form>
      -    {% for obj in filter %}
      -        {{ obj.name }} - ${{ obj.price }}<br />
      -    {% endfor %}
      -{% endblock %}
      -
      -
      -

      And that’s all there is to it! The form attribute contains a normal -Django form, and when we iterate over the FilterSet we get the objects in -the resulting queryset.

      -
      -
      -

      Other Meta options

      -
      -

      Ordering using order_by

      -

      You can allow the user to control ordering by providing the -order_by argument in the Filter’s Meta class. order_by can be either a -list or tuple of field names, in which case those are the options, or -it can be a bool which, if True, indicates that all fields that -the user can filter on can also be sorted on. An example or ordering using a list:

      -
      import django_filters
      -
      -class ProductFilter(django_filters.FilterSet):
      -    price = django_filters.NumberFilter(lookup_type='lt')
      -    class Meta:
      -        model = Product
      -        fields = ['price', 'release_date']
      -        order_by = ['price']
      -
      -
      -

      If you want to control the display of items in order_by, you can set it to -a list or tuple of 2-tuples in the format (field_name, display_name). -This lets you override the displayed names for your ordering fields:

      -
      order_by = (
      -    ('name', 'Company Name'),
      -    ('average_rating', 'Stars'),
      -)
      -
      -
      -

      Note that the default query parameter name used for ordering is o. You -can override this by setting an order_by_field attribute on the -FilterSet class to the string value you would like to use.

      -
      -
      -

      Custom Forms using form

      -

      The inner Meta class also takes an optional form argument. This is a -form class from which FilterSet.form will subclass. This works similar to -the form option on a ModelAdmin.

      -
      -
      -
      -

      Non-Meta options

      -

      Note that these options do not go in the Meta class, they are specified directly -in your FilterSet class.

      -
      -

      strict

      -

      The strict option controls whether results are returned when an invalid -value is specified by the user for any filter field. By default, strict is -set to True meaning that an empty queryset is returned if any field contains -an invalid value. You can loosen this behavior by setting strict to -False which will effectively ignore a filter field if its value is invalid.

      -
      -
      -
      -

      Overriding FilterSet methods

      -
      -

      get_ordering_field()

      -

      If you want to use a custom widget, or in any other way override the ordering -field you can override the get_ordering_field() method on a FilterSet. -This method just needs to return a Form Field.

      -

      Ordering on multiple fields, or other complex orderings can be achieved by -overriding the Filterset.get_order_by() method. This is passed the selected -order_by value, and is expected to return an iterable of values to pass to -QuerySet.order_by. For example, to sort a User table by last name, then -first name:

      -
      class UserFilter(django_filters.FilterSet):
      -    class Meta:
      -        order_by = (
      -            ('username', 'Username'),
      -            ('last_name', 'Last Name')
      -        )
      -
      -    def get_order_by(self, order_value):
      -        if order_value == 'last_name':
      -            return ['last_name', 'first_name']
      -        return super(UserFilter, self).get_order_by(order_value)
      -
      -
      -
      -
      -
      -

      Generic View

      -

      In addition to the above usage there is also a class-based generic view -included in django-filter, which lives at django_filters.views.FilterView. -You must provide either a model or filterset_class argument, similar to -ListView in Django itself:

      -
      # urls.py
      -from django.conf.urls import patterns, url
      -from django_filters.views import FilterView
      -from myapp.models import Product
      -
      -urlpatterns = patterns('',
      -    (r'^list/$', FilterView.as_view(model=Product)),
      -)
      -
      -
      -

      You must provide a template at <app>/<model>_filter.html which gets the -context parameter filter. Additionally, the context will contain -object_list which holds the filtered queryset.

      -

      A legacy functional generic view is still included in django-filter, although -its use is deprecated. It can be found at -django_filters.views.object_filter. You must provide the same arguments -to it as the class based view:

      -
      # urls.py
      -from django.conf.urls import patterns, url
      -from myapp.models import Product
      -
      -urlpatterns = patterns('',
      -    (r'^list/$', 'django_filters.views.object_filter', {'model': Product}),
      -)
      -
      -
      -

      The needed template and its context variables will also be the same as the -class-based view above.

      -
      -
      - - -
      -
      -
      -
      -
      -

      Table Of Contents

      - - -

      Previous topic

      -

      Installing django-filter

      -

      Next topic

      -

      Filter Reference

      -

      This Page

      - - - -
      -
      -
      -
      - - - - \ No newline at end of file diff -Nru django-filter-0.11.0/docs/conf.py django-filter-0.13.0/docs/conf.py --- django-filter-0.11.0/docs/conf.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/docs/conf.py 2016-03-11 19:42:49.000000000 +0000 @@ -48,9 +48,9 @@ # built documents. # # The short X.Y version. -version = '0.11.0' +version = '0.13.0' # The full version, including alpha/beta/rc tags. -release = '0.11.0' +release = '0.13.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -183,7 +183,7 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('asd', 'django-filter.tex', u'django-filter Documentation', + ('index', 'django-filter.tex', u'django-filter Documentation', u'Alex Gaynor and others.', 'manual'), ] @@ -213,7 +213,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('asd', 'django-filter', u'django-filter Documentation', + ('index', 'django-filter', u'django-filter Documentation', [u'Alex Gaynor and others.'], 1) ] @@ -227,7 +227,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('asd', 'django-filter', u'django-filter Documentation', + ('index', 'django-filter', u'django-filter Documentation', u'Alex Gaynor and others.', 'django-filter', 'One line description of project.', 'Miscellaneous'), ] diff -Nru django-filter-0.11.0/docs/index.txt django-filter-0.13.0/docs/index.txt --- django-filter-0.11.0/docs/index.txt 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/docs/index.txt 2016-03-11 19:42:49.000000000 +0000 @@ -14,7 +14,9 @@ install usage + ref/filterset ref/filters ref/fields ref/widgets + ref/settings tests diff -Nru django-filter-0.11.0/docs/install.txt django-filter-0.13.0/docs/install.txt --- django-filter-0.11.0/docs/install.txt 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/docs/install.txt 2016-03-11 19:42:49.000000000 +0000 @@ -1,5 +1,8 @@ Installing django-filter ------------------------ -To install, simply place the ``django_filters`` directory somewhere on your -``PYTHONPATH``, and then add ``'django_filters'`` to your ``INSTALLED_APPS``. +Install with pip: + + pip install django-filter + +And then add ``'django_filters'`` to your ``INSTALLED_APPS``. diff -Nru django-filter-0.11.0/docs/ref/fields.txt django-filter-0.13.0/docs/ref/fields.txt --- django-filter-0.11.0/docs/ref/fields.txt 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/docs/ref/fields.txt 2016-03-11 19:42:49.000000000 +0000 @@ -16,5 +16,5 @@ f.input_formats = [IsoDateTimeField.ISO_8601] + DateTimeField.input_formats -.. _`DateTimeField Docs`:https://docs.djangoproject.com/en/1.8/ref/forms/fields/#django.forms.DateTimeField.input_formats +.. _`DateTimeField Docs`: https://docs.djangoproject.com/en/1.8/ref/forms/fields/#django.forms.DateTimeField.input_formats diff -Nru django-filter-0.11.0/docs/ref/filterset.txt django-filter-0.13.0/docs/ref/filterset.txt --- django-filter-0.11.0/docs/ref/filterset.txt 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/docs/ref/filterset.txt 2016-03-11 19:42:49.000000000 +0000 @@ -0,0 +1,164 @@ +FilterSet Guide +=============== + +This document provides a guide on using additional FilterSet features. + +Meta options +------------ + +- model +- fields +- exclude +- :ref:`order_by ` +- :ref:`form
      ` +- :ref:`together ` + + +.. _order-by: + +Ordering using ``order_by`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can allow the user to control ordering by providing the +``order_by`` argument in the Filter's Meta class. ``order_by`` can be either a +``list`` or ``tuple`` of field names, in which case those are the options, or +it can be a ``bool`` which, if True, indicates that all fields that +the user can filter on can also be sorted on. An example of ordering using a list:: + + import django_filters + + class ProductFilter(django_filters.FilterSet): + price = django_filters.NumberFilter(lookup_expr='lt') + class Meta: + model = Product + fields = ['price', 'release_date'] + order_by = ['price'] + +If you want to control the display of items in ``order_by``, you can set it to +a list or tuple of 2-tuples in the format ``(field_name, display_name)``. +This lets you override the displayed names for your ordering fields:: + + order_by = ( + ('name', 'Company Name'), + ('average_rating', 'Stars'), + ) + +Note that the default query parameter name used for ordering is ``o``. You +can override this by setting an ``order_by_field`` attribute on the +``FilterSet`` class to the string value you would like to use. + + +.. _form: + +Custom Forms using ``form`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The inner ``Meta`` class also takes an optional ``form`` argument. This is a +form class from which ``FilterSet.form`` will subclass. This works similar to +the ``form`` option on a ``ModelAdmin.`` + + +.. _together: + +Group fields with ``together`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The inner ``Meta`` class also takes an optional ``together`` argument. This +is a list of lists, each containing field names. For convenience can be a +single list/tuple when dealing with a single set of fields. Fields within a +field set must either be all or none present in the request for +``FilterSet.form`` to be valid:: + + import django_filters + + class ProductFilter(django_filters.FilterSet): + class Meta: + model = Product + fields = ['price', 'release_date', 'rating'] + together = ['rating', 'price'] + + +Non-Meta options +---------------- + +Note that these options do not go in the Meta class, they are specified directly +in your FilterSet class. + +- filter_overrides +- order_by_field +- :ref:`strict ` + + +.. _strict: + +``strict`` +~~~~~~~~~~ + +The ``strict`` option controls whether results are returned when an invalid +value is specified by the user for any filter field. By default, ``strict`` is +set to ``STRICTNESS.RETURN_NO_RESULTS`` meaning that an empty queryset is +returned if any field contains an invalid value. You can loosen this behavior +by setting ``strict`` to ``STRICTNESS.IGNORE`` which will effectively ignore a +filter field if its value is invalid. A third option of +``STRICTNESS.RAISE_VALIDATION_ERROR`` will cause a ``ValidationError`` to be +raised if any field contains an invalid value. + +Overriding ``FilterSet`` methods +-------------------------------- + +``filter_for_lookup()`` +~~~~~~~~~~~~~~~~~~~~~~~ + +Prior to version 0.13.0, filter generation did not take into account the +``lookup_expr`` used. This commonly caused malformed filters to be generated +for 'isnull', 'in', and 'range' lookups (as well as transformed lookups). The +current implementation provides the following behavior: + +- 'isnull' lookups return a ``BooleanFilter`` +- 'in' lookups return a filter derived from the CSV-based ``BaseInFilter``. +- 'range' lookups return a filter derived from the CSV-based ``BaseRangeFilter``. + +If you want to override the ``filter_class`` and ``params`` used to instantiate +filters for a model field, you can override ``filter_for_lookup()``. Ex:: + + class ProductFilter(django_filters.FilterSet): + class Meta: + model = Product + fields = { + 'release_date': ['exact', 'range'], + } + + @classmethod + def filter_for_lookup(cls, f, lookup_type): + # override date range lookups + if isinstance(f, models.DateField) and lookup_type == 'range': + return django_filters.DateRangeFiler, {} + + # use default behavior otherwise + return super(ProductFilter, cls).filter_for_lookup(f, lookup_type) + + +``get_ordering_field()`` +~~~~~~~~~~~~~~~~~~~~~~~~ + +If you want to use a custom widget, or in any other way override the ordering +field you can override the ``get_ordering_field()`` method on a ``FilterSet``. +This method just needs to return a Form Field. + +Ordering on multiple fields, or other complex orderings can be achieved by +overriding the ``FilterSet.get_order_by()`` method. This is passed the selected +``order_by`` value, and is expected to return an iterable of values to pass to +``QuerySet.order_by``. For example, to sort a ``User`` table by last name, then +first name:: + + class UserFilter(django_filters.FilterSet): + class Meta: + order_by = ( + ('username', 'Username'), + ('last_name', 'Last Name') + ) + + def get_order_by(self, order_value): + if order_value == 'last_name': + return ['last_name', 'first_name'] + return super(UserFilter, self).get_order_by(order_value) diff -Nru django-filter-0.11.0/docs/ref/filters.txt django-filter-0.13.0/docs/ref/filters.txt --- django-filter-0.11.0/docs/ref/filters.txt 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/docs/ref/filters.txt 2016-03-11 19:42:49.000000000 +0000 @@ -3,6 +3,124 @@ This is a reference document with a list of the filters and their arguments. +.. _core-arguments: + +Core Arguments +-------------- + +The following are the core arguments that apply to all filters. + +``name`` +~~~~~~~~ + +The name of the field this filter is supposed to filter on, if this is not +provided it automatically becomes the filter's name on the ``FilterSet``. +You can traverse "relationship paths" using Django's ``__`` syntax to filter +fields on a related model. eg, ``manufacturer__name``. + +``label`` +~~~~~~~~~ + +The label as it will apear in the HTML, analogous to a form field's label +argument. + +``widget`` +~~~~~~~~~~ + +The django.form Widget class which will represent the ``Filter``. In addition +to the widgets that are included with Django that you can use there are +additional ones that django-filter provides which may be useful: + + * :ref:`LinkWidget ` -- this displays the options in a manner + similar to the way the Django Admin does, as a series of links. The link + for the selected option will have ``class="selected"``. + * :ref:`BooleanWidget ` -- this widget converts its input + into Python's True/False values. It will convert all case variations of + ``True`` and ``False`` into the internal Python values. + * :ref:`CSVWidget ` -- this widget expects a comma separated + value and converts it into a list of string values. It is expected that + the field class handle a list of values as well as type conversion. + +``action`` +~~~~~~~~~~ + +An optional callable that tells the filter how to handle the queryset. It +recieves a ``QuerySet`` and the value to filter on and should return a +``Queryset`` that is filtered appropriately. `action` will default to +``filter_{value-of-name-attribute}`` + +``lookup_expr`` +~~~~~~~~~~~~~~~ + +The lookup expression that should be performed using `Django's ORM`_. + +.. _`Django's ORM`: https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups + +A ``list`` or ``tuple`` of lookup types is also accepted, allowing the user to +select the lookup from a dropdown. The list of lookup types are filtered against +``filters.LOOKUP_TYPES``. If `lookup_expr=None` is passed, then a list of all lookup +types will be generated:: + + class ProductFilter(django_filters.FilterSet): + name = django_filters.CharFilter(lookup_expr=['exact', 'iexact']) + +You can enable custom lookups by adding them to ``LOOKUP_TYPES``:: + + from django_filters import filters + + filters.LOOKUP_TYPES = ['gt', 'gte', 'lt', 'lte', 'custom_lookup_type'] + +Additionally, you can provide human-friendly help text by overriding ``LOOKUP_TYPES``:: + + # filters.py + from django_filters import filters + + filters.LOOKUP_TYPES = [ + ('', '---------'), + ('exact', 'Is equal to'), + ('not_exact', 'Is not equal to'), + ('lt', 'Lesser than'), + ('gt', 'Greater than'), + ('gte', 'Greater than or equal to'), + ('lte', 'Lesser than or equal to'), + ('startswith', 'Starts with'), + ('endswith', 'Ends with'), + ('contains', 'Contains'), + ('not_contains', 'Does not contain'), + ] + + +``distinct`` +~~~~~~~~~~~~ + +A boolean value that specifies whether the Filter will use distinct on the +queryset. This option can be used to eliminate duplicate results when using filters that span related models. Defaults to ``False``. + +``exclude`` +~~~~~~~~~~~ + +A boolean value that specifies whether the Filter should use ``filter`` or ``exclude`` on the queryset. +Defaults to ``False``. + + +``**kwargs`` +~~~~~~~~~~~~ + +Any additional keyword arguments are stored as the ``extra`` parameter on the filter. They are provided to the accompanying form Field and can be used to provide arguments like ``choices``. + + +ModelChoiceFilter and ModelMultipleChoiceFilter arguments +--------------------------------------------------------- + +These arguments apply specifically to ModelChoiceFiler and +ModelMultipleChoiceFilter only. + +``queryset`` +~~~~~~~~~~~~ + +``ModelChoiceFilter`` and ``ModelMultipleChoiceFilter`` require a queryset to operate on which must be passed as a kwarg. + + Filters ------- @@ -12,6 +130,11 @@ This filter does simple character matches, used with ``CharField`` and ``TextField`` by default. +``UUIDFilter`` +~~~~~~~~~~~~~~ + +This filter matches UUID values, used with ``models.UUIDField`` by default. + ``BooleanFilter`` ~~~~~~~~~~~~~~~~~ @@ -132,6 +255,16 @@ If automatically instantiated ``ModelChoiceFilter`` will use the default ``QuerySet`` for the related field. If manually instantiated you **must** provide the ``queryset`` kwarg. +Example. :: + + class F(FilterSet): + """Filter for books by author""" + author = ModelChoiceFilter(queryset=Author.objects.all()) + + class Meta: + model = Book + fields = ['author'] + ``ModelMultipleChoiceFilter`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -156,7 +289,7 @@ the Postgres Numerical Range Fields, including `IntegerRangeField`, `BigIntegerRangeField` and `FloatRangeField`, available since Django 1.8. The default widget used is the `RangeField`. -RangeField lookup_types can be used, including `overlap`, `contains`, and `contained_by`. More lookups can be +RangeField lookup_exprs can be used, including `overlap`, `contains`, and `contained_by`. More lookups can be found in the Django docs ([https://docs.djangoproject.com/en/1.8/ref/contrib/postgres/fields/#querying-range-fields](https://docs.djangoproject.com/en/1.8/ref/contrib/postgres/fields/#querying-range-fields)). If the lower limit value is provided, the filter automatically defaults to `__startswith` as the lookup @@ -196,14 +329,118 @@ ``DateFromToRangeFilter`` ~~~~~~~~~~~~~~~~~~~~~~~~~ -Similar to a ``RangeFilter`` except it uses dates instead of numerical values. It can be used with ``DateField`` and ``DateTimeField``. +Similar to a ``RangeFilter`` except it uses dates instead of numerical values. It can be used with ``DateField``. It also works with ``DateTimeField``, but takes into consideration only the date. + +Example of using the ``DateField`` field:: + + class Comment(models.Model): + date = models.DateField() + time = models.TimeField() + + class F(FilterSet): + date = DateFromToRangeFilter() + + class Meta: + model = Comment + fields = ['date'] + + # Range: Comments added between 2016-01-01 and 2016-02-01 + f = F({'date_0': '2016-01-01', 'date_1': '2016-02-01'}) + + # Min-Only: Comments added after 2016-01-01 + f = F({'date_0': '2016-01-01'}) + + # Max-Only: Comments added before 2016-02-01 + f = F({'date_1': '2016-02-01'}) + +Example of using the ``DateTimeField`` field:: + + class Article(models.Model): + published = models.DateTimeField() + + class F(FilterSet): + published = DateFromToRangeFilter() + + class Meta: + model = Article + fields = ['published'] + + Article.objects.create(published='2016-01-01 8:00') + Article.objects.create(published='2016-01-20 10:00') + Article.objects.create(published='2016-02-10 12:00') + + # Range: Articles published between 2016-01-01 and 2016-02-01 + f = F({'published_0': '2016-01-01', 'published_1': '2016-02-01'}) + assert len(f.qs) == 2 + + # Min-Only: Articles published after 2016-01-01 + f = F({'published_0': '2016-01-01'}) + assert len(f.qs) == 3 + + # Max-Only: Articles published before 2016-02-01 + f = F({'published_1': '2016-02-01'}) + assert len(f.qs) == 2 + +``DateTimeFromToRangeFilter`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Similar to a ``RangeFilter`` except it uses datetime format values instead of numerical values. It can be used with ``DateTimeField``. + +Example:: + + class Article(models.Model): + published = models.DateTimeField() + + class F(FilterSet): + published = DateTimeFromToRangeFilter() + + class Meta: + model = Article + fields = ['published'] + Article.objects.create(published='2016-01-01 8:00') + Article.objects.create(published='2016-01-01 9:30') + Article.objects.create(published='2016-01-02 8:00') + + # Range: Articles published 2016-01-01 between 8:00 and 10:00 + f = F({'published_0': '2016-01-01 8:00', 'published_1': '2016-01-01 10:00'}) + assert len(f.qs) == 2 + + # Min-Only: Articles published after 2016-01-01 8:00 + f = F({'published_0': '2016-01-01 8:00'}) + assert len(f.qs) == 3 + + # Max-Only: Articles published before 2016-01-01 10:00 + f = F({'published_1': '2016-01-01 10:00'}) + assert len(f.qs) == 2 ``TimeRangeFilter`` ~~~~~~~~~~~~~~~~~~~ Similar to a ``RangeFilter`` except it uses time format values instead of numerical values. It can be used with ``TimeField``. +Example:: + + class Comment(models.Model): + date = models.DateField() + time = models.TimeField() + + class F(FilterSet): + time = TimeRangeFilter() + + class Meta: + model = Comment + fields = ['time'] + + # Range: Comments added between 8:00 and 10:00 + f = F({'time_0': '8:00', 'time_1': '10:00'}) + + # Min-Only: Comments added after 8:00 + f = F({'time_0': '8:00'}) + + # Max-Only: Comments added before 10:00 + f = F({'time_1': '10:00'}) + ``AllValuesFilter`` ~~~~~~~~~~~~~~~~~~~ @@ -212,80 +449,75 @@ each of those is present as an option. This is similar to the default behavior of the admin. -``MethodFilter`` -~~~~~~~~~~~~~~~~~~~ - -This is a ``Filter`` that will allow you to run a method that exists on the filter set that -this filter is a property of. Set the `action` to a string that will map to a method on the -filter set class. - -Core Arguments --------------- - -``name`` -~~~~~~~~ - -The name of the field this filter is supposed to filter on, if this is not -provided it automatically becomes the filter's name on the ``FilterSet``. +``BaseInFilter`` +~~~~~~~~~~~~~~~~ -``label`` -~~~~~~~~~ +This is a base class used for generating IN lookup filters. Values are expected to be comma separated. -The label as it will apear in the HTML, analogous to a form field's label -argument. +Example. :: -``widget`` -~~~~~~~~~~ + class NumberInFilter(BaseInFilter, NumericFilter): + pass -The django.form Widget class which will represent the ``Filter``. In addition -to the widgets that are included with Django that you can use there are -additional ones that django-filter provides which may be useful: + class F(FilterSet): + id__in = NumberInFilter(name=id, lookup_expr='in') - * ``django_filters.widgets.LinkWidget`` -- this displays the options in a - mannner similar to the way the Django Admin does, as a series of links. - The link for the selected option will have ``class="selected"``. + class Meta: + model = User -``action`` -~~~~~~~~~~ + User.objects.create(username='alex') + User.objects.create(username='jacob') + User.objects.create(username='aaron') + User.objects.create(username='carl') + + # In: User with IDs 1 and 3. + f = F({'id__in': '1,3'}) + assert len(f.qs) == 2 -An optional callable that tells the filter how to handle the queryset. It -recieves a ``QuerySet`` and the value to filter on and should return a -``Queryset`` that is filtered appropriately. +``BaseRangeFilter`` +~~~~~~~~~~~~~~~~~~~ -``lookup_type`` -~~~~~~~~~~~~~~~ +This is a base class used for generating RANGE lookup filters. The base class expects two values two, separated by a comma. -The type of lookup that should be performed using the [Django ORM](https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups "Django's ORM Lookups"). -All the normal options are allowed, and should be provided as a string. You can also -provide either ``None`` or a ``list`` or a ``tuple``. If ``None`` is provided, -then the user can select the lookup type from all the ones available in the Django -ORM. If a ``list`` or ``tuple`` is provided, then the user can select from those -options. +Example. :: -``distinct`` -~~~~~~~~~~~~ + class NumberRangeFilter(BaseInFilter, NumericFilter): + pass -A boolean value that specifies whether the Filter will use distinct on the -queryset. This option can be used to eliminate duplicate results when using filters that span related models. Defaults to ``False``. + class F(FilterSet): + id__range = NumberRangeFilter(name=id, lookup_expr='range') -``exclude`` -~~~~~~~~~~~ + class Meta: + model = User -A boolean value that specifies whether the Filter should use ``filter`` or ``exclude`` on the queryset. -Defaults to ``False``. + User.objects.create(username='alex') + User.objects.create(username='jacob') + User.objects.create(username='aaron') + User.objects.create(username='carl') + + # Range: User with IDs between 1 and 3. + f = F({'id__range': '1,3'}) + assert len(f.qs) == 3 -ModelChoiceFilter and ModelMultipleChoiceFilter --------------- +``MethodFilter`` +~~~~~~~~~~~~~~~~ -``queryset`` -~~~~~~~~~~~ +This is a ``Filter`` that will allow you to run a method that exists on the filter set that +this filter is a property of. Set the `action` to a string that will map to a method on the +filter set class. `action` will default to ``filter_{value-of-name-attribute}`` -``ModelChoiceFilter`` and ``ModelMultipleChoiceFilter`` require a queryset to operate on which must be passed as a kwarg. +Example. :: + class F(FilterSet): + """Filter for Books by if books are published or not""" + published = MethodFilter() -``**kwargs`` -~~~~~~~~~~~~ + def filter_published(self, queryset, value): + if value: + return queryset.filter(published__isnull=False) + return queryset -Any extra keyword arguments will be provided to the accompanying form Field. -This can be used to provide arguments like ``choices``. + class Meta: + model = Book + fields = ['published'] diff -Nru django-filter-0.11.0/docs/ref/settings.txt django-filter-0.13.0/docs/ref/settings.txt --- django-filter-0.11.0/docs/ref/settings.txt 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/docs/ref/settings.txt 2016-03-11 19:42:49.000000000 +0000 @@ -0,0 +1,24 @@ +.. _ref-settings: + +================== +Available Settings +================== + +Here is a list of all available settings of django-filters and their +default values. All settings are prefixed with ``FILTERS_``, although this +is a bit verbose it helps to make it easy to identify these settings. + + +FILTERS_HELP_TEXT_EXCLUDE +------------------------- + +Default: ``True`` + +Enable / disable the default field ``help_text`` on filters where ``exclude=True`` (:doc:`/ref/filters`). This does not affect fields which explicitly define ``help_text``. + +FILTERS_HELP_TEXT_FILTER +------------------------ + +Default: ``True`` + +Enable / disable the default field ``help_text`` on filters where ``exclude=False`` (:doc:`/ref/filters`). This does not affect fields which explicitly define ``help_text``. diff -Nru django-filter-0.11.0/docs/ref/widgets.txt django-filter-0.13.0/docs/ref/widgets.txt --- django-filter-0.11.0/docs/ref/widgets.txt 2014-09-25 13:15:14.000000000 +0000 +++ django-filter-0.13.0/docs/ref/widgets.txt 2016-03-11 19:42:49.000000000 +0000 @@ -4,16 +4,41 @@ This is a reference document with a list of the provided widgets and their arguments. + +.. _link-widget: + ``LinkWidget`` ~~~~~~~~~~~~~~ This widget renders each option as a link, instead of an actual . It has -one method that you can overide for additional customizability. +one method that you can override for additional customizability. ``option_string()`` should return a string with 3 Python keyword argument -placeholders:: +placeholders: 1. ``attrs``: This is a string with all the attributes that will be on the final ```` tag. 2. ``query_string``: This is the query string for use in the ``href`` - option on the ```` elemeent. + option on the ```` element. 3. ``label``: This is the text to be displayed to the user. + + +.. _boolean-widget: + +``BooleanWidget`` +~~~~~~~~~~~~~~~~~ + +This widget converts its input into Python's True/False values. It will convert +all case variations of ``True`` and ``False`` into the internal Python values. +To use it, pass this into the ``widgets`` argument of the ``BooleanFilter``:: + + active = BooleanFilter(widget=BooleanWidget()) + + +.. _csv-widget: + +``CSVWidget`` +~~~~~~~~~~~~~ + +This widget expects a comma separated value and converts it into a list of +string values. It is expected that the field class handle a list of values as +well as type conversion. diff -Nru django-filter-0.11.0/docs/usage.txt django-filter-0.13.0/docs/usage.txt --- django-filter-0.11.0/docs/usage.txt 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/docs/usage.txt 2016-03-11 19:42:49.000000000 +0000 @@ -28,6 +28,8 @@ import django_filters class ProductFilter(django_filters.FilterSet): + name = django_filters.CharFilter(lookup_expr='iexact') + class Meta: model = Product fields = ['price', 'release_date'] @@ -35,42 +37,109 @@ As you can see this uses a very similar API to Django's ``ModelForm``. Just like with a ``ModelForm`` we can also override filters, or add new ones using a -declarative syntax:: +declarative syntax. + +Declaring filters +~~~~~~~~~~~~~~~~~ + +The declarative syntax provides you with the most flexibility when creating +filters, however it is fairly verbose. We'll use the below example to outline +the :ref:`core filter arguments ` on a ``FilterSet``:: + + class ProductFilter(django_filters.FilterSet): + price = django_filters.NumberFilter() + price__gt = django_filters.NumberFilter(name='price', lookup_expr='gt') + price__lt = django_filters.NumberFilter(name='price', lookup_expr='lt') + + release_year = django_filters.NumberFilter(name='release_date', lookup_expr='year') + release_year__gt = django_filters.NumberFilter(name='release_date', lookup_expr='year__gt') + release_year__lt = django_filters.NumberFilter(name='release_date', lookup_expr='year__lt') + + manufacturer__name = django_filters.CharFilter(lookup_expr='icontains') + + class Meta: + model = Product + +There are two main arguments for filters: + +- ``name``: The name of the model field to filter on. You can traverse + "relationship paths" using Django's ``__`` syntax to filter fields on a + related model. ex, ``manufacturer__name``. +- ``lookup_expr``: The `field lookup`_ to use when filtering. Django's ``__`` + syntax can again be used in order to support lookup transforms. + ex, ``year__gte``. + +.. _`field lookup`: https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups + +Together, the field ``name`` and ``lookup_expr`` represent a complete Django +lookup expression. A detailed explanation of lookup expressions is provided in +Django's `lookup reference`_. django-filter supports expressions containing +both transforms and a final lookup for version 1.9 of Django and above. +For Django version 1.8, transformed expressions are not supported. + +.. _`lookup reference`: https://docs.djangoproject.com/en/dev/ref/models/lookups/#module-django.db.models.lookups + +While both of these fields are optional, it is recommended that you specify +them. By default, if ``name`` is not specified, the filter's name on the +filterset class will be used. Additionally, ``lookup_expr`` defaults to +``exact``. The following is an example of a misconfigured price filter:: + + class ProductFilter(django_filters.FilterSet): + price__gt = django_filters.NumberFilter() + +The filter instance will have a field name of ``price__gt`` and an ``exact`` +lookup type. Under the hood, this will incorrectly be resolved as:: + + Produce.objects.filter(price__gt__exact=value) + +.. note:: + + It's quite common to forget to set the lookup expression for + :code:`CharField` and :code:`TextField` and wonder why a search for "foo" + does not return results for "foobar". This is because the default lookup + type is `exact`, but you probably want to perform an `icontains` lookup. + +For more information on additional arguments, see :ref:`core-arguments`. + + +Generating filters with Meta.fields +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The FilterSet Meta class provides a ``fields`` attribute that can be used for +easily specifying multiple filters without significant code duplication. The +base syntax supports a list of multiple field names:: import django_filters class ProductFilter(django_filters.FilterSet): - price = django_filters.NumberFilter(lookup_type='lt') class Meta: model = Product fields = ['price', 'release_date'] -Filters take a ``lookup_type`` argument which specifies what lookup type to -use with `Django's ORM`_. So here when a user entered a price it would show all -Products with a price less than that. - -.. _`Django's ORM`: https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups - -**It's quite common to forget to set lookup type for `CharField`s/`TextField`s -and wonder why search for "foo" doesn't return result for "foobar". It's because -default lookup type is exact text, but you probably want `icontains` lookup -field.** +The above generates 'exact' lookups for both the 'price' and 'release_date' +fields. -The FilterSet Meta class fields can additionally be set using a Dictionary to -specify multiple ``lookup_type`` filters without significant code duplication:: +Additionally, a dictionary can be used to specify multiple lookup expressions +for each field:: import django_filters class ProductFilter(django_filters.FilterSet): class Meta: model = Product - fields = {'price': ['lt', 'gt'], - 'release_date': ['exact'], - } - -The above would generate 'price__lt', 'price__gt' and 'release_date' filters. -The filter lookup type keyword 'exact' is the default and therefore never added -to a filter name. + fields = { + 'price': ['lt', 'gt'], + 'release_date': ['exact', 'year__gt'], + } + +The above would generate 'price__lt', 'price__gt', 'release_date', and +'release_date__year__gt' filters. + +.. note:: + + The filter lookup type 'exact' is an implicit default and therefore never + added to a filter name. In the above example, the release date's exact + filter is 'release_date', not 'release_date__exact'. Items in the ``fields`` sequence in the ``Meta`` class may include "relationship paths" using Django's ``__`` syntax to filter on fields on a @@ -81,20 +150,9 @@ model = Product fields = ['manufacturer__country'] -Filters also take any arbitrary keyword arguments which get passed onto the -``django.forms.Field`` initializer. These extra keyword arguments get stored -in ``Filter.extra``, so it's possible to override the initializer of a -``FilterSet`` to add extra ones:: - class ProductFilter(django_filters.FilterSet): - class Meta: - model = Product - fields = ['manufacturer'] - - def __init__(self, *args, **kwargs): - super(ProductFilter, self).__init__(*args, **kwargs) - self.filters['manufacturer'].extra.update( - {'empty_label': 'All Manufacturers'}) +Overriding default filters +"""""""""""""""""""""""""" Like ``django.contrib.admin.ModelAdmin``, it is possible to override default filters for all the models fields of the same kind using @@ -105,18 +163,28 @@ models.CharField: { 'filter_class': django_filters.CharFilter, 'extra': lambda f: { - 'lookup_type': 'icontains', - } - } + 'lookup_expr': 'icontains', + }, + }, + models.BooleanField: { + 'filter_class': django_filters.BooleanFilter, + 'extra': lambda f: { + 'widget': 'forms.CheckboxInput', + }, + }, } class Meta: model = Product - fields = ['name'] + fields = { + 'name': ['exact'], + 'release_date': ['isnull'], + } + +Custom filtering with MethodFilter +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -MethodFilter -~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you want fine control over each individual filter attribute, you can use the ``MethodFilter`` filter. @@ -150,7 +218,7 @@ class F(django_filters.FilterSet): # Notice: In this case, action accepts a func, not a string - username = MethodFilter(action=filter_username) + username = MethodFilter(action=my_custom_filter) class Meta: model = User @@ -173,7 +241,7 @@ username__contains='ke' ) -Under the hood, if ``action`` not is defined, ``django_filter`` +Under the hood, if ``action`` is not defined, ``django_filter`` searches for a class method with a name that follows the pattern ``filter_{{ATTRIBUTE_NAME}}``. For example, if the attribute name is ``email``, then the filter class will be scanned for the filter function @@ -188,7 +256,7 @@ def product_list(request): f = ProductFilter(request.GET, queryset=Product.objects.all()) - return render_to_response('my_app/template.html', {'filter': f}) + return render(request, 'my_app/template.html', {'filter': f}) If a queryset argument isn't provided then all the items in the default manager of the model will be used. @@ -196,6 +264,7 @@ If you want to access the filtered objects in your views, for example if you want to paginate them, you can do that. They are in f.qs + The URL conf ------------ @@ -203,6 +272,7 @@ url(r'^list$', views.product_list) + The template ------------ @@ -224,113 +294,9 @@ Django form, and when we iterate over the ``FilterSet`` we get the objects in the resulting queryset. -Other Meta options ------------------- - -Ordering using ``order_by`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can allow the user to control ordering by providing the -``order_by`` argument in the Filter's Meta class. ``order_by`` can be either a -``list`` or ``tuple`` of field names, in which case those are the options, or -it can be a ``bool`` which, if True, indicates that all fields that -the user can filter on can also be sorted on. An example or ordering using a list:: - - import django_filters - - class ProductFilter(django_filters.FilterSet): - price = django_filters.NumberFilter(lookup_type='lt') - class Meta: - model = Product - fields = ['price', 'release_date'] - order_by = ['price'] - -If you want to control the display of items in ``order_by``, you can set it to -a list or tuple of 2-tuples in the format ``(field_name, display_name)``. -This lets you override the displayed names for your ordering fields:: - - order_by = ( - ('name', 'Company Name'), - ('average_rating', 'Stars'), - ) - -Note that the default query parameter name used for ordering is ``o``. You -can override this by setting an ``order_by_field`` attribute on the -``FilterSet`` class to the string value you would like to use. - -Custom Forms using ``form`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The inner ``Meta`` class also takes an optional ``form`` argument. This is a -form class from which ``FilterSet.form`` will subclass. This works similar to -the ``form`` option on a ``ModelAdmin.`` - -Group fields with ``together`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The inner ``Meta`` class also takes an optional ``together`` argument. This -is a list of lists, each containing field names. For convenience can be a -single list/tuple when dealing with a single set of fields. Fields within a -field set must either be all or none present in the request for -``FilterSet.form`` to be valid:: - - import django_filters - - class ProductFilter(django_filters.FilterSet): - class Meta: - model = Product - fields = ['price', 'release_date', 'rating'] - together = ['rating', 'price'] - - -Non-Meta options ----------------- - -Note that these options do not go in the Meta class, they are specified directly -in your FilterSet class. - -``strict`` -~~~~~~~~~~ - -The ``strict`` option controls whether results are returned when an invalid -value is specified by the user for any filter field. By default, ``strict`` is -set to ``STRICTNESS.RETURN_NO_RESULTS`` meaning that an empty queryset is -returned if any field contains an invalid value. You can loosen this behavior -by setting ``strict`` to ``STRICTNESS.IGNORE`` which will effectively ignore a -filter field if its value is invalid. A third option of -``STRICTNESS.RAISE_VALIDATION_ERROR`` will cause a ``ValidationError` to be -raised if any field contains an invalid value. - -Overriding ``FilterSet`` methods --------------------------------- -``get_ordering_field()`` -~~~~~~~~~~~~~~~~~~~~~~~~ - -If you want to use a custom widget, or in any other way override the ordering -field you can override the ``get_ordering_field()`` method on a ``FilterSet``. -This method just needs to return a Form Field. - -Ordering on multiple fields, or other complex orderings can be achieved by -overriding the ``FilterSet.get_order_by()`` method. This is passed the selected -``order_by`` value, and is expected to return an iterable of values to pass to -``QuerySet.order_by``. For example, to sort a ``User`` table by last name, then -first name:: - - class UserFilter(django_filters.FilterSet): - class Meta: - order_by = ( - ('username', 'Username'), - ('last_name', 'Last Name') - ) - - def get_order_by(self, order_value): - if order_value == 'last_name': - return ['last_name', 'first_name'] - return super(UserFilter, self).get_order_by(order_value) - -Generic View ------------- +Generic view & configuration +----------------------------- In addition to the above usage there is also a class-based generic view included in django-filter, which lives at ``django_filters.views.FilterView``. diff -Nru django-filter-0.11.0/MANIFEST.in django-filter-0.13.0/MANIFEST.in --- django-filter-0.11.0/MANIFEST.in 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/MANIFEST.in 2016-03-11 19:42:49.000000000 +0000 @@ -8,3 +8,4 @@ recursive-include requirements * recursive-include tests * recursive-include django_filters/locale * +prune docs/_build \ No newline at end of file diff -Nru django-filter-0.11.0/PKG-INFO django-filter-0.13.0/PKG-INFO --- django-filter-0.11.0/PKG-INFO 2015-08-14 10:22:02.000000000 +0000 +++ django-filter-0.13.0/PKG-INFO 2016-03-11 19:44:01.000000000 +0000 @@ -1,10 +1,10 @@ Metadata-Version: 1.1 Name: django-filter -Version: 0.11.0 +Version: 0.13.0 Summary: Django-filter is a reusable Django application for allowing users to filter querysets dynamically. -Home-page: http://github.com/alex/django-filter/tree/master -Author: Alex Gaynor -Author-email: alex.gaynor@gmail.com +Home-page: http://github.com/carltongibson/django-filter/tree/master +Author: Carlton Gibson +Author-email: carlton.gibson@noumenal.es License: BSD Description: Django Filter ============= @@ -14,14 +14,14 @@ Full documentation on `read the docs`_. - .. image:: https://secure.travis-ci.org/alex/django-filter.png?branch=master - :target: http://travis-ci.org/alex/django-filter + .. image:: https://travis-ci.org/carltongibson/django-filter.svg?branch=master + :target: https://travis-ci.org/carltongibson/django-filter Requirements ------------ - * Python 2.6+ - * Django 1.4.5+ + * Python 2.7, 3.2, 3.3, 3.4, 3.5 + * Django 1.8, 1.9 Installation ------------ @@ -32,7 +32,7 @@ Or clone the repo and add to your PYTHONPATH:: - git clone git@github.com:alex/django-filter.git + git clone git@github.com:carltongibson/django-filter.git Usage ----- @@ -54,11 +54,11 @@ def product_list(request): filter = ProductFilter(request.GET, queryset=Product.objects.all()) - return render_to_response('my_app/template.html', {'filter': filter}) + return render(request, 'my_app/template.html', {'filter': filter}) Django-filters additionally supports specifying FilterSet fields using a dictionary to specify filters with lookup types:: - + import django_filters class ProductFilter(django_filters.FilterSet): @@ -87,10 +87,10 @@ Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 Classifier: Framework :: Django diff -Nru django-filter-0.11.0/README.rst django-filter-0.13.0/README.rst --- django-filter-0.11.0/README.rst 2014-09-25 13:15:14.000000000 +0000 +++ django-filter-0.13.0/README.rst 2016-03-11 19:42:49.000000000 +0000 @@ -6,14 +6,14 @@ Full documentation on `read the docs`_. -.. image:: https://secure.travis-ci.org/alex/django-filter.png?branch=master - :target: http://travis-ci.org/alex/django-filter +.. image:: https://travis-ci.org/carltongibson/django-filter.svg?branch=master + :target: https://travis-ci.org/carltongibson/django-filter Requirements ------------ -* Python 2.6+ -* Django 1.4.5+ +* Python 2.7, 3.2, 3.3, 3.4, 3.5 +* Django 1.8, 1.9 Installation ------------ @@ -24,7 +24,7 @@ Or clone the repo and add to your PYTHONPATH:: - git clone git@github.com:alex/django-filter.git + git clone git@github.com:carltongibson/django-filter.git Usage ----- @@ -46,11 +46,11 @@ def product_list(request): filter = ProductFilter(request.GET, queryset=Product.objects.all()) - return render_to_response('my_app/template.html', {'filter': filter}) + return render(request, 'my_app/template.html', {'filter': filter}) Django-filters additionally supports specifying FilterSet fields using a dictionary to specify filters with lookup types:: - + import django_filters class ProductFilter(django_filters.FilterSet): diff -Nru django-filter-0.11.0/requirements/docs.txt django-filter-0.13.0/requirements/docs.txt --- django-filter-0.11.0/requirements/docs.txt 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/requirements/docs.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -Sphinx diff -Nru django-filter-0.11.0/requirements/maintainer.txt django-filter-0.13.0/requirements/maintainer.txt --- django-filter-0.11.0/requirements/maintainer.txt 2014-11-28 15:04:27.000000000 +0000 +++ django-filter-0.13.0/requirements/maintainer.txt 2016-03-11 19:42:49.000000000 +0000 @@ -1 +1,30 @@ -bumpversion +alabaster==0.7.7 +argh==0.26.1 +Babel==2.2.0 +backports.ssl-match-hostname==3.4.0.2 +bumpversion==0.5.3 +certifi==2015.9.6.2 +coverage==3.7.1 +django-discover-runner==1.0 +docutils==0.12 +funcsigs==0.4 +Jinja2==2.8 +livereload==2.4.0 +MarkupSafe==0.23 +mock==1.3.0 +pathtools==0.1.2 +pbr==1.7.0 +pkginfo==1.2.1 +Pygments==2.1.3 +pytz==2015.7 +PyYAML==3.11 +requests==2.9.1 +requests-toolbelt==0.6.0 +six==1.9.0 +snowballstemmer==1.2.1 +Sphinx==1.3.6 +sphinx-autobuild==0.5.2 +sphinx-rtd-theme==0.1.9 +tornado==4.2.1 +twine==1.6.5 +watchdog==0.8.3 diff -Nru django-filter-0.11.0/requirements/test.txt django-filter-0.13.0/requirements/test.txt --- django-filter-0.11.0/requirements/test.txt 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/requirements/test.txt 2016-01-07 19:51:07.000000000 +0000 @@ -1,4 +1,4 @@ +coverage==3.7.1 django-discover-runner mock -coverage sphinx-autobuild diff -Nru django-filter-0.11.0/requirements/travis-ci.txt django-filter-0.13.0/requirements/travis-ci.txt --- django-filter-0.11.0/requirements/travis-ci.txt 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/requirements/travis-ci.txt 2015-11-13 08:10:15.000000000 +0000 @@ -1,3 +1,3 @@ django-discover-runner mock -coverage +coverage==3.7.1 diff -Nru django-filter-0.11.0/runshell.py django-filter-0.13.0/runshell.py --- django-filter-0.11.0/runshell.py 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/runshell.py 2016-01-07 19:51:07.000000000 +0000 @@ -1,29 +1,12 @@ #!/usr/bin/env python +import os import sys -from django.conf import settings -from django.core.management import call_command from django.core.management import execute_from_command_line -if not settings.configured: - settings.configure( - DATABASES={ - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:', - }, - }, - INSTALLED_APPS=( - 'django_filters', - 'tests', - ), - ROOT_URLCONF=None, - USE_TZ=True, - SECRET_KEY='foobar' - ) - def runshell(): - call_command('syncdb', interactive=False) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings") + execute_from_command_line(sys.argv[:1] + ['migrate', '--noinput', '-v', '0']) argv = sys.argv[:1] + ['shell'] + sys.argv[1:] execute_from_command_line(argv) diff -Nru django-filter-0.11.0/runtests.py django-filter-0.13.0/runtests.py --- django-filter-0.11.0/runtests.py 2014-09-25 13:15:14.000000000 +0000 +++ django-filter-0.13.0/runtests.py 2016-01-07 19:51:07.000000000 +0000 @@ -1,37 +1,11 @@ #!/usr/bin/env python +import os import sys -from django import VERSION -from django.conf import settings from django.core.management import execute_from_command_line -if not settings.configured: - test_runners_args = {} - if VERSION < (1, 6): - test_runners_args = { - 'TEST_RUNNER': 'discover_runner.DiscoverRunner', - } - settings.configure( - DATABASES={ - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:', - }, - }, - INSTALLED_APPS=( - 'django.contrib.contenttypes', - 'django.contrib.auth', - 'django_filters', - 'tests', - ), - ROOT_URLCONF=None, - USE_TZ=True, - SECRET_KEY='foobar', - SILENCED_SYSTEM_CHECKS=['1_7.W001'], - **test_runners_args - ) - def runtests(): + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings") argv = sys.argv[:1] + ['test'] + sys.argv[1:] execute_from_command_line(argv) diff -Nru django-filter-0.11.0/setup.py django-filter-0.13.0/setup.py --- django-filter-0.11.0/setup.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/setup.py 2016-03-11 19:42:49.000000000 +0000 @@ -6,11 +6,17 @@ readme = f.read() f.close() -version = '0.11.0' +version = '0.13.0' if sys.argv[-1] == 'publish': - os.system("python setup.py sdist upload") - os.system("python setup.py bdist_wheel upload") + if os.system("pip freeze | grep wheel"): + print("wheel not installed.\nUse `pip install wheel`.\nExiting.") + sys.exit() + if os.system("pip freeze | grep twine"): + print("twine not installed.\nUse `pip install twine`.\nExiting.") + sys.exit() + os.system("python setup.py sdist bdist_wheel") + os.system("twine upload dist/*") print("You probably want to also tag the version now:") print(" git tag -a %s -m 'version %s'" % (version, version)) print(" git push --tags") @@ -24,7 +30,9 @@ long_description=readme, author='Alex Gaynor', author_email='alex.gaynor@gmail.com', - url='http://github.com/alex/django-filter/tree/master', + maintainer='Carlton Gibson', + maintainer_email='carlton.gibson@noumenal.es', + url='http://github.com/carltongibson/django-filter/tree/master', packages=find_packages(exclude=['tests']), package_data = { 'django_filters': [ @@ -39,12 +47,12 @@ 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'Framework :: Django', ], include_package_data=True, diff -Nru django-filter-0.11.0/tests/models.py django-filter-0.13.0/tests/models.py --- django-filter-0.11.0/tests/models.py 2014-11-28 15:04:27.000000000 +0000 +++ django-filter-0.13.0/tests/models.py 2016-03-11 19:42:49.000000000 +0000 @@ -31,10 +31,10 @@ models.Field.__init__(self, *args, **kwargs) def get_internal_type(self): - return "IPAddressField" + return "GenericIPAddressField" def formfield(self, **kwargs): - defaults = {'form_class': forms.IPAddressField} + defaults = {'form_class': forms.GenericIPAddressField} defaults.update(kwargs) return super(SubnetMaskField, self).formfield(**defaults) @@ -67,7 +67,7 @@ @python_2_unicode_compatible class Comment(models.Model): text = models.TextField() - author = models.ForeignKey(User, related_name='comments') + author = models.ForeignKey(User, related_name='comments', on_delete=models.CASCADE) date = models.DateField() time = models.TimeField() @@ -78,7 +78,7 @@ class Article(models.Model): published = models.DateTimeField() - author = models.ForeignKey(User, null=True) + author = models.ForeignKey(User, null=True, on_delete=models.CASCADE) def __str__(self): if self.author_id: @@ -108,7 +108,7 @@ class NetworkSetting(models.Model): - ip = models.IPAddressField() + ip = models.GenericIPAddressField() mask = SubnetMaskField() @@ -125,7 +125,7 @@ @python_2_unicode_compatible class Location(models.Model): - company = models.ForeignKey(Company, related_name='locations') + company = models.ForeignKey(Company, related_name='locations', on_delete=models.CASCADE) name = models.CharField(max_length=100) zip_code = models.CharField(max_length=10) open_days = models.CharField(max_length=7) @@ -141,7 +141,7 @@ class Profile(models.Model): - account = models.OneToOneField(Account, related_name='profile') + account = models.OneToOneField(Account, related_name='profile', on_delete=models.CASCADE) likes_coffee = models.BooleanField(default=False) likes_tea = models.BooleanField(default=False) @@ -169,8 +169,8 @@ class HiredWorker(models.Model): salary = models.IntegerField() hired_on = models.DateField() - worker = models.ForeignKey(Worker) - business = models.ForeignKey('Business') + worker = models.ForeignKey(Worker, on_delete=models.CASCADE) + business = models.ForeignKey('Business', on_delete=models.CASCADE) class Business(models.Model): @@ -179,3 +179,6 @@ through=HiredWorker, related_name='employers') + +class UUIDTestModel(models.Model): + uuid = models.UUIDField() diff -Nru django-filter-0.11.0/tests/settings.py django-filter-0.13.0/tests/settings.py --- django-filter-0.11.0/tests/settings.py 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/tests/settings.py 2016-01-07 19:51:07.000000000 +0000 @@ -0,0 +1,29 @@ +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': ':memory:', + }, +} + +INSTALLED_APPS = ( + 'django.contrib.contenttypes', + 'django.contrib.auth', + 'django_filters', + 'tests', +) + +ROOT_URLCONF = 'tests.urls' + +USE_TZ = True + +SECRET_KEY = 'foobar' + +TEMPLATES = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'APP_DIRS': True, +}] + + +SILENCED_SYSTEM_CHECKS = [ + '1_7.W001', # Unset MIDDLEWARE_CLASSES warning +] diff -Nru django-filter-0.11.0/tests/test_fields.py django-filter-0.13.0/tests/test_fields.py --- django-filter-0.11.0/tests/test_fields.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/tests/test_fields.py 2016-03-11 19:42:49.000000000 +0000 @@ -1,27 +1,40 @@ from __future__ import absolute_import from __future__ import unicode_literals -from datetime import datetime, time +from datetime import datetime, time, timedelta, tzinfo import decimal -import sys - -if sys.version_info >= (2, 7): - import unittest -else: # pragma: nocover - from django.utils import unittest # noqa +import unittest import django from django import forms -from django.test import TestCase +from django.test import TestCase, override_settings +from django.utils.timezone import make_aware, get_default_timezone from django_filters.widgets import RangeWidget from django_filters.fields import ( - RangeField, LookupTypeField, Lookup, DateRangeField, TimeRangeField, IsoDateTimeField) + Lookup, LookupTypeField, BaseCSVField, BaseRangeField, RangeField, + DateRangeField, DateTimeRangeField, TimeRangeField, IsoDateTimeField +) + def to_d(float_value): return decimal.Decimal('%.2f' % float_value) +class LookupBoolTests(TestCase): + def test_lookup_true(self): + self.assertTrue(Lookup(True, 'exact')) + self.assertTrue(Lookup(1, 'exact')) + self.assertTrue(Lookup('1', 'exact')) + self.assertTrue(Lookup(datetime.now(), 'exact')) + + def test_lookup_false(self): + self.assertFalse(Lookup(False, 'exact')) + self.assertFalse(Lookup(0, 'exact')) + self.assertFalse(Lookup('', 'exact')) + self.assertFalse(Lookup(None, 'exact')) + + class RangeFieldTests(TestCase): def test_field(self): @@ -43,16 +56,32 @@ f = DateRangeField() self.assertEqual(len(f.fields), 2) + @override_settings(USE_TZ=False) def test_clean(self): w = RangeWidget() f = DateRangeField(widget=w) - self.assertEqual( f.clean(['2015-01-01', '2015-01-10']), - slice(datetime(2015, 1, 1, 0, 0 , 0), + slice(datetime(2015, 1, 1, 0, 0, 0), datetime(2015, 1, 10, 23, 59, 59, 999999))) +class DateTimeRangeFieldTests(TestCase): + + def test_field(self): + f = DateTimeRangeField() + self.assertEqual(len(f.fields), 2) + + @override_settings(USE_TZ=False) + def test_clean(self): + w = RangeWidget() + f = DateTimeRangeField(widget=w) + self.assertEqual( + f.clean(['2015-01-01 10:30', '2015-01-10 8:45']), + slice(datetime(2015, 1, 1, 10, 30, 0), + datetime(2015, 1, 10, 8, 45, 0))) + + class TimeRangeFieldTests(TestCase): def test_field(self): @@ -120,13 +149,94 @@ class IsoDateTimeFieldTests(TestCase): + reference_str = "2015-07-19T13:34:51.759" + reference_dt = datetime(2015, 7, 19, 13, 34, 51, 759000) def test_datetime_string_is_parsed(self): f = IsoDateTimeField() - d = f.strptime("2015-07-19T13:34:51.759", IsoDateTimeField.ISO_8601) + d = f.strptime(self.reference_str + "", IsoDateTimeField.ISO_8601) self.assertTrue(isinstance(d, datetime)) def test_datetime_string_with_timezone_is_parsed(self): f = IsoDateTimeField() - d = f.strptime("2015-07-19T13:34:51.759+01:00", IsoDateTimeField.ISO_8601) - self.assertTrue(isinstance(d, datetime)) \ No newline at end of file + d = f.strptime(self.reference_str + "+01:00", IsoDateTimeField.ISO_8601) + self.assertTrue(isinstance(d, datetime)) + + def test_datetime_zulu(self): + f = IsoDateTimeField() + d = f.strptime(self.reference_str + "Z", IsoDateTimeField.ISO_8601) + self.assertTrue(isinstance(d, datetime)) + + def test_datetime_timezone_awareness(self): + # parsed datetimes should obey USE_TZ + f = IsoDateTimeField() + r = make_aware(self.reference_dt, get_default_timezone()) + + d = f.strptime(self.reference_str + "+01:00", IsoDateTimeField.ISO_8601) + self.assertTrue(isinstance(d.tzinfo, tzinfo)) + self.assertEqual(d, r + r.utcoffset() - d.utcoffset()) + + d = f.strptime(self.reference_str + "", IsoDateTimeField.ISO_8601) + self.assertTrue(isinstance(d.tzinfo, tzinfo)) + self.assertEqual(d, r) + + @override_settings(USE_TZ=False) + def test_datetime_timezone_naivety(self): + # parsed datetimes should obey USE_TZ + f = IsoDateTimeField() + r = self.reference_dt.replace() + + d = f.strptime(self.reference_str + "+01:00", IsoDateTimeField.ISO_8601) + self.assertTrue(d.tzinfo is None) + self.assertEqual(d, r - timedelta(hours=1)) + + d = f.strptime(self.reference_str + "", IsoDateTimeField.ISO_8601) + self.assertTrue(d.tzinfo is None) + self.assertEqual(d, r) + + +class BaseCSVFieldTests(TestCase): + def setUp(self): + class DecimalCSVField(BaseCSVField, forms.DecimalField): + pass + + self.field = DecimalCSVField() + + def test_clean(self): + self.assertEqual(self.field.clean(None), None) + self.assertEqual(self.field.clean(''), []) + self.assertEqual(self.field.clean(['1']), [1]) + self.assertEqual(self.field.clean(['1', '2']), [1, 2]) + self.assertEqual(self.field.clean(['1', '2', '3']), [1, 2, 3]) + + def test_validation_error(self): + with self.assertRaises(forms.ValidationError): + self.field.clean(['']) + + with self.assertRaises(forms.ValidationError): + self.field.clean(['a', 'b', 'c']) + + +class BaseRangeFieldTests(TestCase): + def setUp(self): + class DecimalRangeField(BaseRangeField, forms.DecimalField): + pass + + self.field = DecimalRangeField() + + def test_clean(self): + self.assertEqual(self.field.clean(None), None) + self.assertEqual(self.field.clean(['1', '2']), [1, 2]) + + def test_validation_error(self): + with self.assertRaises(forms.ValidationError): + self.field.clean('') + + with self.assertRaises(forms.ValidationError): + self.field.clean(['']) + + with self.assertRaises(forms.ValidationError): + self.field.clean(['1']) + + with self.assertRaises(forms.ValidationError): + self.field.clean(['1', '2', '3']) diff -Nru django-filter-0.11.0/tests/test_filtering.py django-filter-0.13.0/tests/test_filtering.py --- django-filter-0.11.0/tests/test_filtering.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/tests/test_filtering.py 2016-03-11 19:42:49.000000000 +0000 @@ -3,29 +3,29 @@ import datetime import mock -import sys +import unittest -if sys.version_info >= (2, 7): - import unittest -else: # pragma: nocover - from django.utils import unittest # noqa - -from django.test import TestCase +import django +from django.test import TestCase, override_settings from django.utils import six from django.utils.timezone import now from django.utils import timezone from django_filters.filterset import FilterSet from django_filters.filters import AllValuesFilter +from django_filters.filters import BaseInFilter from django_filters.filters import CharFilter from django_filters.filters import ChoiceFilter from django_filters.filters import DateRangeFilter +from django_filters.filters import DateFromToRangeFilter +from django_filters.filters import DateTimeFromToRangeFilter # from django_filters.filters import DateTimeFilter from django_filters.filters import MethodFilter from django_filters.filters import MultipleChoiceFilter from django_filters.filters import ModelMultipleChoiceFilter from django_filters.filters import NumberFilter from django_filters.filters import RangeFilter +from django_filters.filters import TimeRangeFilter # from django_filters.widgets import LinkWidget from .models import User @@ -451,9 +451,9 @@ f = F({'price': 10}, queryset=Book.objects.all()) self.assertQuerysetEqual(f.qs, ['Ender\'s Game'], lambda o: o.title) - def test_filtering_with_single_lookup_type(self): + def test_filtering_with_single_lookup_expr(self): class F(FilterSet): - price = NumberFilter(lookup_type='lt') + price = NumberFilter(lookup_expr='lt') class Meta: model = Book @@ -463,7 +463,7 @@ self.assertQuerysetEqual( f.qs, ['Ender\'s Game', 'Rainbow Six'], lambda o: o.title) - def test_filtering_with_single_lookup_type_dictionary(self): + def test_filtering_with_single_lookup_expr_dictionary(self): class F(FilterSet): class Meta: model = Book @@ -473,9 +473,9 @@ self.assertQuerysetEqual( f.qs, ['Ender\'s Game', 'Rainbow Six'], lambda o: o.title) - def test_filtering_with_multiple_lookup_types(self): + def test_filtering_with_multiple_lookup_exprs(self): class F(FilterSet): - price = NumberFilter(lookup_type=['lt', 'gt']) + price = NumberFilter(lookup_expr=['lt', 'gt']) class Meta: model = Book @@ -492,7 +492,7 @@ lambda o: o.title, ordered=False) class F(FilterSet): - price = NumberFilter(lookup_type=['lt', 'gt', 'exact']) + price = NumberFilter(lookup_expr=['lt', 'gt', 'exact']) class Meta: model = Book @@ -624,6 +624,102 @@ # different things to both user and server. +class DateFromToRangeFilterTests(TestCase): + + def test_filtering(self): + adam = User.objects.create(username='adam') + kwargs = {'text': 'test', 'author': adam, 'time': '10:00'} + Comment.objects.create(date=datetime.date(2016, 1, 1), **kwargs) + Comment.objects.create(date=datetime.date(2016, 1, 2), **kwargs) + Comment.objects.create(date=datetime.date(2016, 1, 3), **kwargs) + Comment.objects.create(date=datetime.date(2016, 1, 3), **kwargs) + + class F(FilterSet): + published = DateFromToRangeFilter(name='date') + + class Meta: + model = Comment + fields = ['date'] + + results = F(data={ + 'published_0': '2016-01-02', + 'published_1': '2016-01-03'}) + self.assertEqual(len(results.qs), 3) + + def test_filtering_ignores_time(self): + tz = timezone.get_current_timezone() + Article.objects.create( + published=datetime.datetime(2016, 1, 1, 10, 0, tzinfo=tz)) + Article.objects.create( + published=datetime.datetime(2016, 1, 2, 12, 45, tzinfo=tz)) + Article.objects.create( + published=datetime.datetime(2016, 1, 3, 18, 15, tzinfo=tz)) + Article.objects.create( + published=datetime.datetime(2016, 1, 3, 19, 30, tzinfo=tz)) + + class F(FilterSet): + published = DateFromToRangeFilter() + + class Meta: + model = Article + fields = ['published'] + + results = F(data={ + 'published_0': '2016-01-02', + 'published_1': '2016-01-03'}) + self.assertEqual(len(results.qs), 3) + + +class DateTimeFromToRangeFilterTests(TestCase): + + def test_filtering(self): + tz = timezone.get_current_timezone() + Article.objects.create( + published=datetime.datetime(2016, 1, 1, 10, 0, tzinfo=tz)) + Article.objects.create( + published=datetime.datetime(2016, 1, 2, 12, 45, tzinfo=tz)) + Article.objects.create( + published=datetime.datetime(2016, 1, 3, 18, 15, tzinfo=tz)) + Article.objects.create( + published=datetime.datetime(2016, 1, 3, 19, 30, tzinfo=tz)) + + class F(FilterSet): + published = DateTimeFromToRangeFilter() + + class Meta: + model = Article + fields = ['published'] + + results = F(data={ + 'published_0': '2016-01-02 10:00', + 'published_1': '2016-01-03 19:00'}) + self.assertEqual(len(results.qs), 2) + + +class TimeRangeFilterTests(TestCase): + + def test_filtering(self): + adam = User.objects.create(username='adam') + kwargs = { + 'text': 'test', 'author': adam, 'date': datetime.date.today()} + Comment.objects.create(time='7:30', **kwargs) + Comment.objects.create(time='8:00', **kwargs) + Comment.objects.create(time='9:30', **kwargs) + Comment.objects.create(time='11:00', **kwargs) + + class F(FilterSet): + time = TimeRangeFilter() + + class Meta: + model = Comment + fields = ['time'] + + results = F(data={ + 'time_0': '8:00', + 'time_1': '10:00'}) + self.assertEqual(len(results.qs), 2) + + class AllValuesFilterTests(TestCase): def test_filtering(self): @@ -1245,6 +1341,189 @@ self.assertQuerysetEqual(f.qs, [2], lambda o: o.pk) +# use naive datetimes, as pytz is required to perform +# date lookups when timezones are involved. +@override_settings(USE_TZ=False) +@unittest.skipIf(django.VERSION < (1, 9), "version does not support transformed lookup expressions") +class TransformedQueryExpressionFilterTests(TestCase): + + def test_filtering(self): + now_dt = datetime.datetime.now() + after_5pm = now_dt.replace(hour=18) + before_5pm = now_dt.replace(hour=16) + + u = User.objects.create(username='alex') + a = Article.objects.create(author=u, published=after_5pm) + Article.objects.create(author=u, published=before_5pm) + + class F(FilterSet): + class Meta: + model = Article + fields = {'published': ['hour__gte']} + + qs = Article.objects.all() + f = F({'published__hour__gte': 17}, queryset=qs) + self.assertEqual(len(f.qs), 1) + self.assertQuerysetEqual(f.qs, [a.pk], lambda o: o.pk) + + +# use naive datetimes, as pytz is required to perform +# date lookups when timezones are involved. +@override_settings(USE_TZ=False) +class CSVFilterTests(TestCase): + + def setUp(self): + u1 = User.objects.create(username='alex', status=1) + u2 = User.objects.create(username='jacob', status=2) + User.objects.create(username='aaron', status=2) + User.objects.create(username='carl', status=0) + + now_dt = datetime.datetime.now() + after_5pm = now_dt.replace(hour=18) + before_5pm = now_dt.replace(hour=16) + + Article.objects.create(author=u1, published=after_5pm) + Article.objects.create(author=u2, published=after_5pm) + Article.objects.create(author=u1, published=before_5pm) + Article.objects.create(author=u2, published=before_5pm) + + class UserFilter(FilterSet): + class Meta: + model = User + fields = { + 'username': ['in'], + 'status': ['in'], + } + + class ArticleFilter(FilterSet): + class Meta: + model = Article + fields = { + 'author': ['in'], + 'published': ['in'], + } + + self.user_filter = UserFilter + self.article_filter = ArticleFilter + + self.after_5pm = after_5pm.strftime('%Y-%m-%d %H:%M:%S.%f') + self.before_5pm = before_5pm.strftime('%Y-%m-%d %H:%M:%S.%f') + + def test_numeric_filtering(self): + F = self.user_filter + + qs = User.objects.all() + f = F(queryset=qs) + self.assertEqual(len(f.qs), 4) + self.assertEqual(f.count(), 4) + + f = F({'status__in': ''}, queryset=qs) + self.assertEqual(len(f.qs), 0) + self.assertEqual(f.count(), 0) + + f = F({'status__in': '0'}, queryset=qs) + self.assertEqual(len(f.qs), 1) + self.assertEqual(f.count(), 1) + + f = F({'status__in': '0,2'}, queryset=qs) + self.assertEqual(len(f.qs), 3) + self.assertEqual(f.count(), 3) + + f = F({'status__in': '0,,1'}, queryset=qs) + self.assertEqual(len(f.qs), 2) + self.assertEqual(f.count(), 2) + + f = F({'status__in': '2'}, queryset=qs) + self.assertEqual(len(f.qs), 2) + self.assertEqual(f.count(), 2) + + def test_string_filtering(self): + F = self.user_filter + + qs = User.objects.all() + f = F(queryset=qs) + self.assertEqual(len(f.qs), 4) + self.assertEqual(f.count(), 4) + + f = F({'username__in': ''}, queryset=qs) + self.assertEqual(len(f.qs), 0) + self.assertEqual(f.count(), 0) + + f = F({'username__in': 'alex'}, queryset=qs) + self.assertEqual(len(f.qs), 1) + self.assertEqual(f.count(), 1) + + f = F({'username__in': 'alex,aaron'}, queryset=qs) + self.assertEqual(len(f.qs), 2) + self.assertEqual(f.count(), 2) + + f = F({'username__in': 'alex,,aaron'}, queryset=qs) + self.assertEqual(len(f.qs), 2) + self.assertEqual(f.count(), 2) + + f = F({'username__in': 'alex,'}, queryset=qs) + self.assertEqual(len(f.qs), 1) + self.assertEqual(f.count(), 1) + + def test_datetime_filtering(self): + F = self.article_filter + after = self.after_5pm + before = self.before_5pm + + qs = Article.objects.all() + f = F(queryset=qs) + self.assertEqual(len(f.qs), 4) + self.assertEqual(f.count(), 4) + + f = F({'published__in': ''}, queryset=qs) + self.assertEqual(len(f.qs), 0) + self.assertEqual(f.count(), 0) + + f = F({'published__in': '%s' % (after, )}, queryset=qs) + self.assertEqual(len(f.qs), 2) + self.assertEqual(f.count(), 2) + + f = F({'published__in': '%s,%s' % (after, before, )}, queryset=qs) + self.assertEqual(len(f.qs), 4) + self.assertEqual(f.count(), 4) + + f = F({'published__in': '%s,,%s' % (after, before, )}, queryset=qs) + self.assertEqual(len(f.qs), 4) + self.assertEqual(f.count(), 4) + + f = F({'published__in': '%s,' % (after, )}, queryset=qs) + self.assertEqual(len(f.qs), 2) + self.assertEqual(f.count(), 2) + + def test_related_filtering(self): + F = self.article_filter + + qs = Article.objects.all() + f = F(queryset=qs) + self.assertEqual(len(f.qs), 4) + self.assertEqual(f.count(), 4) + + f = F({'author__in': ''}, queryset=qs) + self.assertEqual(len(f.qs), 0) + self.assertEqual(f.count(), 0) + + f = F({'author__in': '1'}, queryset=qs) + self.assertEqual(len(f.qs), 2) + self.assertEqual(f.count(), 2) + + f = F({'author__in': '1,2'}, queryset=qs) + self.assertEqual(len(f.qs), 4) + self.assertEqual(f.count(), 4) + + f = F({'author__in': '1,,2'}, queryset=qs) + self.assertEqual(len(f.qs), 4) + self.assertEqual(f.count(), 4) + + f = F({'author__in': '1,'}, queryset=qs) + self.assertEqual(len(f.qs), 2) + self.assertEqual(f.count(), 2) + + class MiscFilterSetTests(TestCase): def setUp(self): @@ -1331,4 +1610,3 @@ f = F({'status': '2'}, queryset=qs) self.assertEqual(len(f.qs), 2) self.assertEqual(f.count(), 2) - diff -Nru django-filter-0.11.0/tests/test_filterset.py django-filter-0.13.0/tests/test_filterset.py --- django-filter-0.11.0/tests/test_filterset.py 2015-05-13 14:29:24.000000000 +0000 +++ django-filter-0.13.0/tests/test_filterset.py 2016-03-11 19:42:49.000000000 +0000 @@ -1,27 +1,31 @@ from __future__ import absolute_import, unicode_literals import mock -import sys - -if sys.version_info >= (2, 7): - import unittest -else: # pragma: nocover - from django.utils import unittest # noqa +import unittest +import django +from django.core.exceptions import ValidationError from django.db import models from django.test import TestCase from django_filters.filterset import FilterSet from django_filters.filterset import FILTER_FOR_DBFIELD_DEFAULTS -from django_filters.filterset import get_model_field +from django_filters.filterset import STRICTNESS +from django_filters.filters import BooleanFilter from django_filters.filters import CharFilter from django_filters.filters import NumberFilter from django_filters.filters import ChoiceFilter from django_filters.filters import ModelChoiceFilter from django_filters.filters import ModelMultipleChoiceFilter +from django_filters.filters import UUIDFilter +from django_filters.filters import BaseInFilter +from django_filters.filters import BaseRangeFilter + +from django_filters.widgets import BooleanWidget from .models import User from .models import AdminUser +from .models import Article from .models import Book from .models import Profile from .models import Comment @@ -35,6 +39,7 @@ from .models import Worker from .models import HiredWorker from .models import Business +from .models import UUIDTestModel def checkItemsEqual(L1, L2): @@ -43,20 +48,13 @@ """ return len(L1) == len(L2) and sorted(L1) == sorted(L2) + class HelperMethodsTests(TestCase): @unittest.skip('todo') def test_get_declared_filters(self): pass - def test_get_model_field_none(self): - result = get_model_field(User, 'unknown__name') - self.assertIsNone(result) - - def test_get_model_field(self): - result = get_model_field(Business, 'hiredworker__worker') - self.assertEqual(result, HiredWorker._meta.get_field('worker')) - @unittest.skip('todo') def test_filters_for_model(self): pass @@ -80,7 +78,7 @@ models.FilePathField, models.FloatField, models.IntegerField, - models.IPAddressField, + models.GenericIPAddressField, models.NullBooleanField, models.PositiveIntegerField, models.PositiveSmallIntegerField, @@ -92,6 +90,7 @@ models.ForeignKey, models.OneToOneField, models.ManyToManyField, + models.UUIDField, ] msg = "%s expected to be found in FILTER_FOR_DBFIELD_DEFAULTS" @@ -102,7 +101,6 @@ to_check = [ models.Field, models.BigIntegerField, - models.GenericIPAddressField, models.FileField, models.ImageField, ] @@ -120,6 +118,12 @@ self.assertIsInstance(result, CharFilter) self.assertEqual(result.name, 'username') + def test_filter_found_for_uuidfield(self): + f = UUIDTestModel._meta.get_field('uuid') + result = FilterSet.filter_for_field(f, 'uuid') + self.assertIsInstance(result, UUIDFilter) + self.assertEqual(result.name, 'uuid') + def test_filter_found_for_autofield(self): f = User._meta.get_field('id') result = FilterSet.filter_for_field(f, 'id') @@ -175,15 +179,61 @@ self.assertIsNotNone(result.extra['queryset']) self.assertEqual(result.extra['queryset'].model, Worker) + @unittest.skipIf(django.VERSION < (1, 9), "version does not support transformed lookup expressions") + def test_transformed_lookup_expr(self): + f = Comment._meta.get_field('date') + result = FilterSet.filter_for_field(f, 'date', 'year__gte') + self.assertIsInstance(result, NumberFilter) + self.assertEqual(result.name, 'date') + @unittest.skip('todo') def test_filter_overrides(self): pass +class FilterSetFilterForLookupTests(TestCase): + + def test_filter_for_ISNULL_lookup(self): + f = Article._meta.get_field('author') + result, params = FilterSet.filter_for_lookup(f, 'isnull') + self.assertEqual(result, BooleanFilter) + self.assertDictEqual(params, {}) + + def test_filter_for_IN_lookup(self): + f = Article._meta.get_field('author') + result, params = FilterSet.filter_for_lookup(f, 'in') + self.assertTrue(issubclass(result, ModelChoiceFilter)) + self.assertTrue(issubclass(result, BaseInFilter)) + self.assertEqual(params['to_field_name'], 'id') + + def test_filter_for_RANGE_lookup(self): + f = Article._meta.get_field('author') + result, params = FilterSet.filter_for_lookup(f, 'range') + self.assertTrue(issubclass(result, ModelChoiceFilter)) + self.assertTrue(issubclass(result, BaseRangeFilter)) + self.assertEqual(params['to_field_name'], 'id') + + def test_isnull_with_filter_overrides(self): + class OFilterSet(FilterSet): + filter_overrides = { + models.BooleanField: { + 'filter_class': BooleanFilter, + 'extra': lambda f: { + 'widget': BooleanWidget, + }, + }, + } + + f = Article._meta.get_field('author') + result, params = OFilterSet.filter_for_lookup(f, 'isnull') + self.assertEqual(result, BooleanFilter) + self.assertEqual(params['widget'], BooleanWidget) + + class FilterSetFilterForReverseFieldTests(TestCase): def test_reverse_o2o_relationship(self): - f = Account._meta.get_field_by_name('profile')[0] + f = Account._meta.get_field('profile') result = FilterSet.filter_for_reverse_field(f, 'profile') self.assertIsInstance(result, ModelChoiceFilter) self.assertEqual(result.name, 'profile') @@ -192,7 +242,7 @@ self.assertEqual(result.extra['queryset'].model, Profile) def test_reverse_fk_relationship(self): - f = User._meta.get_field_by_name('comments')[0] + f = User._meta.get_field('comments') result = FilterSet.filter_for_reverse_field(f, 'comments') self.assertIsInstance(result, ModelMultipleChoiceFilter) self.assertEqual(result.name, 'comments') @@ -201,7 +251,7 @@ self.assertEqual(result.extra['queryset'].model, Comment) def test_reverse_m2m_relationship(self): - f = Book._meta.get_field_by_name('lovers')[0] + f = Book._meta.get_field('lovers') result = FilterSet.filter_for_reverse_field(f, 'lovers') self.assertIsInstance(result, ModelMultipleChoiceFilter) self.assertEqual(result.name, 'lovers') @@ -210,7 +260,7 @@ self.assertEqual(result.extra['queryset'].model, User) def test_reverse_non_symmetrical_selfref_m2m_field(self): - f = DirectedNode._meta.get_field_by_name('inbound_nodes')[0] + f = DirectedNode._meta.get_field('inbound_nodes') result = FilterSet.filter_for_reverse_field(f, 'inbound_nodes') self.assertIsInstance(result, ModelMultipleChoiceFilter) self.assertEqual(result.name, 'inbound_nodes') @@ -219,7 +269,7 @@ self.assertEqual(result.extra['queryset'].model, DirectedNode) def test_reverse_m2m_field_with_through_model(self): - f = Worker._meta.get_field_by_name('employers')[0] + f = Worker._meta.get_field('employers') result = FilterSet.filter_for_reverse_field(f, 'employers') self.assertIsInstance(result, ModelMultipleChoiceFilter) self.assertEqual(result.name, 'employers') @@ -322,13 +372,15 @@ self.assertTrue(checkItemsEqual(list(F.base_filters), expected_list)) def test_meta_fields_containing_unknown(self): - with self.assertRaises(TypeError): + with self.assertRaises(TypeError) as excinfo: class F(FilterSet): username = CharFilter() class Meta: model = Book fields = ('username', 'price', 'other') + self.assertEqual(excinfo.exception.args, ( + "Meta.fields contains a field that isn't defined on this FilterSet: other",)) def test_meta_fields_dictionary_containing_unknown(self): with self.assertRaises(TypeError): @@ -532,7 +584,21 @@ def test_ordering_on_unknown_value_results_in_default_ordering_without_strict(self): class F(FilterSet): - strict = False + strict = STRICTNESS.IGNORE + + class Meta: + model = User + fields = ['username', 'status'] + order_by = ['status'] + + self.assertFalse(F.strict) + f = F({'o': 'username'}, queryset=self.qs) + self.assertQuerysetEqual( + f.qs, ['alex', 'jacob', 'aaron', 'carl'], lambda o: o.username) + + def test_ordering_on_unknown_value_results_in_default_ordering_with_strict_raise(self): + class F(FilterSet): + strict = STRICTNESS.RAISE_VALIDATION_ERROR class Meta: model = User @@ -540,6 +606,14 @@ order_by = ['status'] f = F({'o': 'username'}, queryset=self.qs) + with self.assertRaises(ValidationError) as excinfo: + f.qs.all() + self.assertEqual(excinfo.exception.message_dict, + {'o': ['Select a valid choice. username is not one ' + 'of the available choices.']}) + + # No default order_by should get applied. + f = F({}, queryset=self.qs) self.assertQuerysetEqual( f.qs, ['alex', 'jacob', 'aaron', 'carl'], lambda o: o.username) @@ -558,20 +632,30 @@ self.assertQuerysetEqual( f.qs, ['carl', 'alex', 'jacob', 'aaron'], lambda o: o.username) - @unittest.skip('todo') def test_ordering_uses_filter_name(self): class F(FilterSet): account = CharFilter(name='username') - class Meta: model = User fields = ['account', 'status'] order_by = True - f = F({'o': 'username'}, queryset=self.qs) + f = F({'o': 'account'}, queryset=self.qs) self.assertQuerysetEqual( f.qs, ['aaron', 'alex', 'carl', 'jacob'], lambda o: o.username) + def test_reverted_ordering_uses_filter_name(self): + class F(FilterSet): + account = CharFilter(name='username') + class Meta: + model = User + fields = ['account', 'status'] + order_by = True + + f = F({'o': '-account'}, queryset=self.qs) + self.assertQuerysetEqual( + f.qs, ['jacob', 'carl', 'alex', 'aaron'], lambda o: o.username) + def test_ordering_with_overridden_field_name(self): """ Set the `order_by_field` on the queryset and ensure that the @@ -642,14 +726,14 @@ self.alex = User.objects.create(username='alex', status=1) self.jacob = User.objects.create(username='jacob', status=2) self.qs = User.objects.all().order_by('id') - + def test_fields_set(self): class F(FilterSet): class Meta: model = User fields = ['username', 'status', 'is_active', 'first_name'] together = [ - ('username', 'status'), + ('username', 'status'), ('first_name', 'is_active'), ] @@ -660,14 +744,14 @@ f = F({'username': 'alex', 'status': 1}, queryset=self.qs) self.assertEqual(f.qs.count(), 1) self.assertQuerysetEqual(f.qs, [self.alex.pk], lambda o: o.pk) - + def test_single_fields_set(self): class F(FilterSet): class Meta: model = User fields = ['username', 'status'] together = ['username', 'status'] - + f = F({}, queryset=self.qs) self.assertEqual(f.qs.count(), 2) f = F({'username': 'alex'}, queryset=self.qs) diff -Nru django-filter-0.11.0/tests/test_filters.py django-filter-0.13.0/tests/test_filters.py --- django-filter-0.11.0/tests/test_filters.py 2015-08-14 10:20:15.000000000 +0000 +++ django-filter-0.13.0/tests/test_filters.py 2016-03-11 19:42:49.000000000 +0000 @@ -1,27 +1,23 @@ from __future__ import absolute_import from __future__ import unicode_literals -from datetime import date, datetime, time +from datetime import date, time, timedelta, datetime import mock -import sys - -if sys.version_info >= (2, 7): - import unittest -else: # pragma: nocover - from django.utils import unittest # noqa - -from datetime import timedelta +import warnings +import unittest from django import forms -from django.test import TestCase - +from django.test import TestCase, override_settings +from django_filters import filters from django_filters.fields import ( Lookup, RangeField, DateRangeField, + DateTimeRangeField, TimeRangeField, - LookupTypeField) + LookupTypeField, + BaseCSVField) from django_filters.filters import ( Filter, CharFilter, @@ -38,8 +34,13 @@ RangeFilter, DateRangeFilter, DateFromToRangeFilter, + DateTimeFromToRangeFilter, TimeRangeFilter, AllValuesFilter, + BaseCSVFilter, + BaseInFilter, + BaseRangeFilter, + UUIDFilter, LOOKUP_TYPES) from tests.models import Book, User @@ -49,7 +50,7 @@ def test_creation(self): f = Filter() - self.assertEqual(f.lookup_type, 'exact') + self.assertEqual(f.lookup_expr, 'exact') self.assertEqual(f.exclude, False) def test_creation_order(self): @@ -69,26 +70,40 @@ self.assertIsInstance(field, forms.Field) self.assertEqual(field.help_text, 'This is an exclusion filter') - def test_field_with_single_lookup_type(self): - f = Filter(lookup_type='iexact') + @override_settings(FILTERS_HELP_TEXT_FILTER=False) + def test_default_field_settings(self): + f = Filter() + field = f.field + self.assertIsInstance(field, forms.Field) + self.assertEqual(field.help_text, '') + + @override_settings(FILTERS_HELP_TEXT_EXCLUDE=False) + def test_field_with_exclusion_settings(self): + f = Filter(exclude=True) + field = f.field + self.assertIsInstance(field, forms.Field) + self.assertEqual(field.help_text, '') + + def test_field_with_single_lookup_expr(self): + f = Filter(lookup_expr='iexact') field = f.field self.assertIsInstance(field, forms.Field) - def test_field_with_none_lookup_type(self): - f = Filter(lookup_type=None) + def test_field_with_none_lookup_expr(self): + f = Filter(lookup_expr=None) field = f.field self.assertIsInstance(field, LookupTypeField) choice_field = field.fields[1] self.assertEqual(len(choice_field.choices), len(LOOKUP_TYPES)) - def test_field_with_lookup_type_and_exlusion(self): - f = Filter(lookup_type=None, exclude=True) + def test_field_with_lookup_expr_and_exlusion(self): + f = Filter(lookup_expr=None, exclude=True) field = f.field self.assertIsInstance(field, LookupTypeField) self.assertEqual(field.help_text, 'This is an exclusion filter') - def test_field_with_list_lookup_type(self): - f = Filter(lookup_type=('istartswith', 'iendswith')) + def test_field_with_list_lookup_expr(self): + f = Filter(lookup_expr=('istartswith', 'iendswith')) field = f.field self.assertIsInstance(field, LookupTypeField) choice_field = field.fields[1] @@ -157,22 +172,22 @@ def test_filtering_with_list_value(self): qs = mock.Mock(spec=['filter']) - f = Filter(name='somefield', lookup_type=['some_lookup_type']) - result = f.filter(qs, Lookup('value', 'some_lookup_type')) - qs.filter.assert_called_once_with(somefield__some_lookup_type='value') + f = Filter(name='somefield', lookup_expr=['some_lookup_expr']) + result = f.filter(qs, Lookup('value', 'some_lookup_expr')) + qs.filter.assert_called_once_with(somefield__some_lookup_expr='value') self.assertNotEqual(qs, result) def test_filtering_skipped_with_list_value_with_blank(self): qs = mock.Mock() - f = Filter(name='somefield', lookup_type=['some_lookup_type']) - result = f.filter(qs, Lookup('', 'some_lookup_type')) + f = Filter(name='somefield', lookup_expr=['some_lookup_expr']) + result = f.filter(qs, Lookup('', 'some_lookup_expr')) self.assertListEqual(qs.method_calls, []) self.assertEqual(qs, result) def test_filtering_skipped_with_list_value_with_blank_lookup(self): - return # Now field is required to provide valid lookup_type if it provides any + return # Now field is required to provide valid lookup_expr if it provides any qs = mock.Mock(spec=['filter']) - f = Filter(name='somefield', lookup_type=None) + f = Filter(name='somefield', lookup_expr=None) result = f.filter(qs, Lookup('value', '')) qs.filter.assert_called_once_with(somefield__exact='value') self.assertNotEqual(qs, result) @@ -189,7 +204,44 @@ qs = mock.Mock(spec=['filter', 'distinct']) f = Filter(name='somefield', distinct=True) f.filter(qs, 'value') - result = qs.distinct.assert_called_once() + result = qs.distinct.assert_called_once_with() + self.assertNotEqual(qs, result) + + def test_lookup_type_deprecation(self): + """ + Make sure user is alerted when using deprecated ``lookup_type``. + """ + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + Filter(lookup_type='exact') + self.assertEqual(len(w), 1) + self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) + + +class CustomFilterWithBooleanCheckTests(TestCase): + + def setUp(self): + super(CustomFilterWithBooleanCheckTests, self).setUp() + + class CustomTestFilter(Filter): + def filter(self_, qs, value): + if not value: + return qs + return super(CustomTestFilter, self_).filter(qs, value) + + self.test_filter_class = CustomTestFilter + + def test_lookup_false(self): + qs = mock.Mock(spec=['filter']) + f = self.test_filter_class(name='somefield') + result = f.filter(qs, Lookup('', 'exact')) + self.assertEqual(qs, result) + + def test_lookup_true(self): + qs = mock.Mock(spec=['filter']) + f = self.test_filter_class(name='somefield') + result = f.filter(qs, Lookup('somesearch', 'exact')) + qs.filter.assert_called_once_with(somefield__exact='somesearch') self.assertNotEqual(qs, result) @@ -201,6 +253,14 @@ self.assertIsInstance(field, forms.CharField) +class UUIDFilterTests(TestCase): + + def test_default_field(self): + f = UUIDFilter() + field = f.field + self.assertIsInstance(field, forms.UUIDField) + + class BooleanFilterTests(TestCase): def test_default_field(self): @@ -212,14 +272,14 @@ qs = mock.Mock(spec=['filter']) f = BooleanFilter(name='somefield') result = f.filter(qs, True) - qs.filter.assert_called_once_with(somefield=True) + qs.filter.assert_called_once_with(somefield__exact=True) self.assertNotEqual(qs, result) def test_filtering_exclude(self): qs = mock.Mock(spec=['exclude']) f = BooleanFilter(name='somefield', exclude=True) result = f.filter(qs, True) - qs.exclude.assert_called_once_with(somefield=True) + qs.exclude.assert_called_once_with(somefield__exact=True) self.assertNotEqual(qs, result) @unittest.expectedFailure @@ -237,6 +297,13 @@ self.assertListEqual(qs.method_calls, []) self.assertEqual(qs, result) + def test_filtering_lookup_expr(self): + qs = mock.Mock(spec=['filter']) + f = BooleanFilter(name='somefield', lookup_expr='isnull') + result = f.filter(qs, True) + qs.filter.assert_called_once_with(somefield__isnull=True) + self.assertNotEqual(qs, result) + class ChoiceFilterTests(TestCase): @@ -493,10 +560,10 @@ result = f.filter(qs, None) self.assertEqual(qs, result) - def test_field_with_lookup_type(self): + def test_field_with_lookup_expr(self): qs = mock.Mock() value = mock.Mock(start=20, stop=30) - f = NumericRangeFilter(lookup_type=('overlap')) + f = NumericRangeFilter(lookup_expr=('overlap')) f.filter(qs, value) qs.filter.assert_called_once_with(None__overlap=(20, 30)) @@ -557,10 +624,10 @@ result = f.filter(qs, None) self.assertEqual(qs, result) - def test_filtering_ignores_lookup_type(self): + def test_filtering_ignores_lookup_expr(self): qs = mock.Mock() value = mock.Mock(start=20, stop=30) - f = RangeFilter(lookup_type='gte') + f = RangeFilter(lookup_expr='gte') f.filter(qs, value) qs.filter.assert_called_once_with(None__range=(20, 30)) @@ -690,15 +757,61 @@ result = f.filter(qs, None) self.assertEqual(qs, result) - def test_filtering_ignores_lookup_type(self): + def test_filtering_ignores_lookup_expr(self): qs = mock.Mock() value = mock.Mock(start=date(2015, 4, 7), stop=date(2015, 9, 6)) - f = DateFromToRangeFilter(lookup_type='gte') + f = DateFromToRangeFilter(lookup_expr='gte') f.filter(qs, value) qs.filter.assert_called_once_with( None__range=(date(2015, 4, 7), date(2015, 9, 6))) +class DateTimeFromToRangeFilterTests(TestCase): + + def test_default_field(self): + f = DateTimeFromToRangeFilter() + field = f.field + self.assertIsInstance(field, DateTimeRangeField) + + def test_filtering_range(self): + qs = mock.Mock(spec=['filter']) + value = mock.Mock( + start=datetime(2015, 4, 7, 8, 30), stop=datetime(2015, 9, 6, 11, 45)) + f = DateTimeFromToRangeFilter() + f.filter(qs, value) + qs.filter.assert_called_once_with( + None__range=(datetime(2015, 4, 7, 8, 30), datetime(2015, 9, 6, 11, 45))) + + def test_filtering_start(self): + qs = mock.Mock(spec=['filter']) + value = mock.Mock(start=datetime(2015, 4, 7, 8, 30), stop=None) + f = DateTimeFromToRangeFilter() + f.filter(qs, value) + qs.filter.assert_called_once_with(None__gte=datetime(2015, 4, 7, 8, 30)) + + def test_filtering_stop(self): + qs = mock.Mock(spec=['filter']) + value = mock.Mock(start=None, stop=datetime(2015, 9, 6, 11, 45)) + f = DateTimeFromToRangeFilter() + f.filter(qs, value) + qs.filter.assert_called_once_with(None__lte=datetime(2015, 9, 6, 11, 45)) + + def test_filtering_skipped_with_none_value(self): + qs = mock.Mock(spec=['filter']) + f = DateTimeFromToRangeFilter() + result = f.filter(qs, None) + self.assertEqual(qs, result) + + def test_filtering_ignores_lookup_type(self): + qs = mock.Mock() + value = mock.Mock( + start=datetime(2015, 4, 7, 8, 30), stop=datetime(2015, 9, 6, 11, 45)) + f = DateTimeFromToRangeFilter(lookup_type='gte') + f.filter(qs, value) + qs.filter.assert_called_once_with( + None__range=(datetime(2015, 4, 7, 8, 30), datetime(2015, 9, 6, 11, 45))) + + class TimeRangeFilterTests(TestCase): def test_default_field(self): @@ -734,10 +847,10 @@ result = f.filter(qs, None) self.assertEqual(qs, result) - def test_filtering_ignores_lookup_type(self): + def test_filtering_ignores_lookup_expr(self): qs = mock.Mock() value = mock.Mock(start=time(10, 15), stop=time(12, 30)) - f = TimeRangeFilter(lookup_type='gte') + f = TimeRangeFilter(lookup_expr='gte') f.filter(qs, value) qs.filter.assert_called_once_with( None__range=(time(10, 15), time(12, 30))) @@ -759,3 +872,115 @@ f.model = mocked field = f.field self.assertIsInstance(field, forms.ChoiceField) + + +class LookupTypesTests(TestCase): + def test_custom_lookup_exprs(self): + filters.LOOKUP_TYPES = [ + ('', '---------'), + ('exact', 'Is equal to'), + ('not_exact', 'Is not equal to'), + ('lt', 'Lesser than'), + ('gt', 'Greater than'), + ('gte', 'Greater than or equal to'), + ('lte', 'Lesser than or equal to'), + ('startswith', 'Starts with'), + ('endswith', 'Ends with'), + ('contains', 'Contains'), + ('not_contains', 'Does not contain'), + ] + + f = Filter(lookup_expr=None) + field = f.field + choice_field = field.fields[1] + all_choices = choice_field.choices + + self.assertIsInstance(field, LookupTypeField) + self.assertEqual(all_choices, filters.LOOKUP_TYPES) + self.assertEqual(all_choices[1][0], 'exact') + self.assertEqual(all_choices[1][1], 'Is equal to') + + custom_f = Filter(lookup_expr=('endswith', 'not_contains')) + custom_field = custom_f.field + custom_choice_field = custom_field.fields[1] + my_custom_choices = custom_choice_field.choices + + available_lookup_exprs = [ + ('endswith', 'Ends with'), + ('not_contains', 'Does not contain'), + ] + + self.assertIsInstance(custom_field, LookupTypeField) + self.assertEqual(my_custom_choices, available_lookup_exprs) + self.assertEqual(my_custom_choices[0][0], 'endswith') + self.assertEqual(my_custom_choices[0][1], 'Ends with') + self.assertEqual(my_custom_choices[1][0], 'not_contains') + self.assertEqual(my_custom_choices[1][1], 'Does not contain') + + +class CSVFilterTests(TestCase): + def setUp(self): + class NumberInFilter(BaseCSVFilter, NumberFilter): + pass + + class DateTimeYearInFilter(BaseCSVFilter, DateTimeFilter): + pass + + self.number_in = NumberInFilter(lookup_expr='in') + self.datetimeyear_in = DateTimeYearInFilter(lookup_expr='year__in') + + def test_default_field(self): + f = BaseCSVFilter() + field = f.field + self.assertIsInstance(field, forms.Field) + + def test_concrete_field(self): + field = self.number_in.field + self.assertIsInstance(field, forms.DecimalField) + self.assertIsInstance(field, BaseCSVField) + self.assertEqual(field.__class__.__name__, 'DecimalInField') + + field = self.datetimeyear_in.field + self.assertIsInstance(field, forms.DateTimeField) + self.assertIsInstance(field, BaseCSVField) + self.assertEqual(field.__class__.__name__, 'DateTimeYearInField') + + def test_filtering(self): + qs = mock.Mock(spec=['filter']) + f = self.number_in + f.filter(qs, [1, 2]) + qs.filter.assert_called_once_with(None__in=[1, 2]) + + def test_filtering_skipped_with_none_value(self): + qs = mock.Mock(spec=['filter']) + f = self.number_in + result = f.filter(qs, None) + self.assertEqual(qs, result) + + def test_field_with_lookup_expr(self): + qs = mock.Mock() + f = self.datetimeyear_in + f.filter(qs, [1, 2]) + qs.filter.assert_called_once_with(None__year__in=[1, 2]) + + +class BaseInFilterTests(TestCase): + def test_filtering(self): + class NumberInFilter(BaseInFilter, NumberFilter): + pass + + qs = mock.Mock(spec=['filter']) + f = NumberInFilter() + f.filter(qs, [1, 2]) + qs.filter.assert_called_once_with(None__in=[1, 2]) + + +class BaseRangeFilterTests(TestCase): + def test_filtering(self): + class NumberInFilter(BaseRangeFilter, NumberFilter): + pass + + qs = mock.Mock(spec=['filter']) + f = NumberInFilter() + f.filter(qs, [1, 2]) + qs.filter.assert_called_once_with(None__range=[1, 2]) diff -Nru django-filter-0.11.0/tests/test_forms.py django-filter-0.13.0/tests/test_forms.py --- django-filter-0.11.0/tests/test_forms.py 2014-09-25 13:15:14.000000000 +0000 +++ django-filter-0.13.0/tests/test_forms.py 2016-01-07 19:51:07.000000000 +0000 @@ -199,7 +199,7 @@ self.assertEqual(f.fields['o'].choices, [('username', 'Account'), ('-username', 'Account (descending)'), ('status', 'Status'), ('-status', 'Status (descending)')]) - def test_ordering_uses_implicit_filter_name(self): + def test_ordering_uses_explicit_filter_name(self): class F(FilterSet): account = CharFilter(name='username') @@ -210,7 +210,7 @@ f = F().form self.assertEqual(f.fields['o'].choices, - [('username', 'Account'), ('-username', 'Account (descending)'), ('status', 'Status'), ('-status', 'Status (descending)')]) + [('account', 'Account'), ('-account', 'Account (descending)'), ('status', 'Status'), ('-status', 'Status (descending)')]) def test_ordering_with_overridden_field_name(self): """ @@ -272,4 +272,3 @@ f = F().form self.assertEqual( f.fields['o'].choices, [('status', 'Current status')]) - diff -Nru django-filter-0.11.0/tests/test_utils.py django-filter-0.13.0/tests/test_utils.py --- django-filter-0.11.0/tests/test_utils.py 1970-01-01 00:00:00.000000000 +0000 +++ django-filter-0.13.0/tests/test_utils.py 2016-03-11 19:42:49.000000000 +0000 @@ -0,0 +1,166 @@ + +import unittest + +import django +from django.test import TestCase +from django.db import models +from django.db.models.constants import LOOKUP_SEP +from django.core.exceptions import FieldError + +from django_filters.utils import get_model_field, resolve_field + +from .models import User +from .models import Article +from .models import Book +from .models import HiredWorker +from .models import Business + + +class GetModelFieldTests(TestCase): + + def test_non_existent_field(self): + result = get_model_field(User, 'unknown__name') + self.assertIsNone(result) + + def test_related_field(self): + result = get_model_field(Business, 'hiredworker__worker') + self.assertEqual(result, HiredWorker._meta.get_field('worker')) + + +class ResolveFieldTests(TestCase): + + def test_resolve_plain_lookups(self): + """ + Check that the standard query terms can be correctly resolved. + eg, an 'EXACT' lookup on a user's username + """ + model_field = User._meta.get_field('username') + lookups = model_field.class_lookups.keys() + + # This is simple - the final ouput of an untransformed field is itself. + # The lookups are the default lookups registered to the class. + for term in lookups: + field, lookup = resolve_field(model_field, term) + self.assertIsInstance(field, models.CharField) + self.assertEqual(lookup, term) + + def test_resolve_forward_related_lookups(self): + """ + Check that lookups can be resolved for related fields + in the forwards direction. + """ + lookups = ['exact', 'gte', 'gt', 'lte', 'lt', 'in', 'isnull', ] + + # ForeignKey + model_field = Article._meta.get_field('author') + for term in lookups: + field, lookup = resolve_field(model_field, term) + self.assertIsInstance(field, models.ForeignKey) + self.assertEqual(lookup, term) + + # ManyToManyField + model_field = User._meta.get_field('favorite_books') + for term in lookups: + field, lookup = resolve_field(model_field, term) + self.assertIsInstance(field, models.ManyToManyField) + self.assertEqual(lookup, term) + + @unittest.skipIf(django.VERSION < (1, 9), "version does not reverse lookups") + def test_resolve_reverse_related_lookups(self): + """ + Check that lookups can be resolved for related fields + in the reverse direction. + """ + lookups = ['exact', 'gte', 'gt', 'lte', 'lt', 'in', 'isnull', ] + + # ManyToOneRel + model_field = User._meta.get_field('article') + for term in lookups: + field, lookup = resolve_field(model_field, term) + self.assertIsInstance(field, models.ManyToOneRel) + self.assertEqual(lookup, term) + + # ManyToManyRel + model_field = Book._meta.get_field('lovers') + for term in lookups: + field, lookup = resolve_field(model_field, term) + self.assertIsInstance(field, models.ManyToManyRel) + self.assertEqual(lookup, term) + + @unittest.skipIf(django.VERSION < (1, 9), "version does not support transformed lookup expressions") + def test_resolve_transformed_lookups(self): + """ + Check that chained field transforms are correctly resolved. + eg, a 'date__year__gte' lookup on an article's 'published' timestamp. + """ + # Use a DateTimeField, so we can check multiple transforms. + # eg, date__year__gte + model_field = Article._meta.get_field('published') + + standard_lookups = [ + 'exact', + 'iexact', + 'gte', + 'gt', + 'lte', + 'lt', + ] + + date_lookups = [ + 'year', + 'month', + 'day', + 'week_day', + ] + + datetime_lookups = date_lookups + [ + 'hour', + 'minute', + 'second', + ] + + # ex: 'date__gt' + for lookup in standard_lookups: + field, resolved_lookup = resolve_field(model_field, LOOKUP_SEP.join(['date', lookup])) + self.assertIsInstance(field, models.DateField) + self.assertEqual(resolved_lookup, lookup) + + # ex: 'year__iexact' + for part in datetime_lookups: + for lookup in standard_lookups: + field, resolved_lookup = resolve_field(model_field, LOOKUP_SEP.join([part, lookup])) + self.assertIsInstance(field, models.IntegerField) + self.assertEqual(resolved_lookup, lookup) + + # ex: 'date__year__lte' + for part in date_lookups: + for lookup in standard_lookups: + field, resolved_lookup = resolve_field(model_field, LOOKUP_SEP.join(['date', part, lookup])) + self.assertIsInstance(field, models.IntegerField) + self.assertEqual(resolved_lookup, lookup) + + @unittest.skipIf(django.VERSION < (1, 9), "version does not support transformed lookup expressions") + def test_resolve_implicit_exact_lookup(self): + # Use a DateTimeField, so we can check multiple transforms. + # eg, date__year__gte + model_field = Article._meta.get_field('published') + + field, lookup = resolve_field(model_field, 'date') + self.assertIsInstance(field, models.DateField) + self.assertEqual(lookup, 'exact') + + field, lookup = resolve_field(model_field, 'date__year') + self.assertIsInstance(field, models.IntegerField) + self.assertEqual(lookup, 'exact') + + def test_invalid_lookup_expression(self): + model_field = Article._meta.get_field('published') + + with self.assertRaises(FieldError): + field, lookup = resolve_field(model_field, 'invalid_lookup') + + def test_invalid_transformed_lookup_expression(self): + model_field = Article._meta.get_field('published') + + with self.assertRaises(FieldError): + field, lookup = resolve_field(model_field, 'date__invalid_lookup') diff -Nru django-filter-0.11.0/tests/test_views.py django-filter-0.13.0/tests/test_views.py --- django-filter-0.11.0/tests/test_views.py 2015-05-13 11:58:23.000000000 +0000 +++ django-filter-0.13.0/tests/test_views.py 2016-01-07 19:51:07.000000000 +0000 @@ -2,7 +2,7 @@ from __future__ import unicode_literals from django.core.exceptions import ImproperlyConfigured -from django.test import TestCase +from django.test import TestCase, override_settings from django.test.client import RequestFactory from django_filters.views import FilterView @@ -11,8 +11,8 @@ from .models import Book +@override_settings(ROOT_URLCONF='tests.urls') class GenericViewTestCase(TestCase): - urls = 'tests.urls' def setUp(self): Book.objects.create( @@ -78,4 +78,3 @@ for b in ['Ender's Game', 'Rainbow Six']: self.assertNotContains(response, b) self.assertContains(response, 'Snowcrash') - diff -Nru django-filter-0.11.0/tests/test_widgets.py django-filter-0.13.0/tests/test_widgets.py --- django-filter-0.11.0/tests/test_widgets.py 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/tests/test_widgets.py 2016-03-11 19:42:49.000000000 +0000 @@ -4,6 +4,8 @@ from django.test import TestCase from django.forms import TextInput, Select +from django_filters.widgets import BooleanWidget +from django_filters.widgets import CSVWidget from django_filters.widgets import RangeWidget from django_filters.widgets import LinkWidget from django_filters.widgets import LookupTypeWidget @@ -135,3 +137,84 @@ - """) + def test_widget_attributes(self): + w = RangeWidget(attrs={'type': 'date'}) + self.assertEqual(len(w.widgets), 2) + self.assertHTMLEqual(w.render('date', ''), """ + + - + """) + + +class BooleanWidgetTests(TestCase): + """ + """ + def test_widget_render(self): + w = BooleanWidget() + self.assertHTMLEqual(w.render('price', ''), """ + """) + + def test_widget_value_from_datadict(self): + """ + """ + w = BooleanWidget() + + trueActive = {'active': 'true'} + result = w.value_from_datadict(trueActive, {}, 'active') + self.assertEqual(result, True) + + falseActive = {'active': 'false'} + result = w.value_from_datadict(falseActive, {}, 'active') + self.assertEqual(result, False) + + result = w.value_from_datadict({}, {}, 'active') + self.assertEqual(result, None) + + +class CSVWidgetTests(TestCase): + def test_widget(self): + w = CSVWidget() + self.assertHTMLEqual(w.render('price', None), """ + """) + + self.assertHTMLEqual(w.render('price', ''), """ + """) + + self.assertHTMLEqual(w.render('price', '1,2'), """ + """) + + self.assertHTMLEqual(w.render('price', ['1', '2']), """ + """) + + self.assertHTMLEqual(w.render('price', [1, 2]), """ + """) + + def test_widget_value_from_datadict(self): + w = CSVWidget() + + data = {'price': None} + result = w.value_from_datadict(data, {}, 'price') + self.assertEqual(result, None) + + data = {'price': '1'} + result = w.value_from_datadict(data, {}, 'price') + self.assertEqual(result, ['1']) + + data = {'price': '1,2'} + result = w.value_from_datadict(data, {}, 'price') + self.assertEqual(result, ['1', '2']) + + data = {'price': '1,,2'} + result = w.value_from_datadict(data, {}, 'price') + self.assertEqual(result, ['1', '', '2']) + + data = {'price': ''} + result = w.value_from_datadict(data, {}, 'price') + self.assertEqual(result, ['']) + + result = w.value_from_datadict({}, {}, 'price') + self.assertEqual(result, None) diff -Nru django-filter-0.11.0/tests/urls.py django-filter-0.13.0/tests/urls.py --- django-filter-0.11.0/tests/urls.py 2014-09-24 17:46:23.000000000 +0000 +++ django-filter-0.13.0/tests/urls.py 2016-01-07 19:51:07.000000000 +0000 @@ -1,14 +1,13 @@ from __future__ import absolute_import from __future__ import unicode_literals -from django.conf.urls import patterns +from django.conf.urls import url -from django_filters.views import FilterView +from django_filters.views import FilterView, object_filter from .models import Book -urlpatterns = patterns('', - (r'^books-legacy/$', - 'django_filters.views.object_filter', {'model': Book}), - (r'^books/$', FilterView.as_view(model=Book)), -) +urlpatterns = [ + url(r'^books-legacy/$', object_filter, {'model': Book}), + url(r'^books/$', FilterView.as_view(model=Book)), +]