From patchwork Sun Jun 24 19:55:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 933969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41DNNK1VxQz9ry1 for ; Mon, 25 Jun 2018 05:56:17 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="eMcA6Q2r"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41DNNJ6kZ9zF14s for ; Mon, 25 Jun 2018 05:56:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="eMcA6Q2r"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.209.62; helo=fossa.birch.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="eMcA6Q2r"; dkim-atps=neutral Received: from fossa.birch.relay.mailchannels.net (fossa.birch.relay.mailchannels.net [23.83.209.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41DNND4wXwzF14g for ; Mon, 25 Jun 2018 05:56:11 +1000 (AEST) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 7A87E5E1391 for ; Sun, 24 Jun 2018 19:56:08 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.26.53]) (Authenticated sender: 5xi41l16bi) by relay.mailchannels.net (Postfix) with ESMTPA id 6DEAF5E133F for ; Sun, 24 Jun 2018 19:56:06 +0000 (UTC) X-Sender-Id: 5xi41l16bi|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.19.51.240]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.15.2); Sun, 24 Jun 2018 19:56:08 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: 5xi41l16bi|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: 5xi41l16bi X-Duck-Cure: 3bbd64fe0fa19296_1529870166656_1926436379 X-MC-Loop-Signature: 1529870166656:4262772492 X-MC-Ingress-Time: 1529870166656 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=m2vkttr/PuCTQJDs2nSSQ52PCyt+bxMMHTCgAgCW5T0=; b=eMcA6Q2rZf3rDEJMUJgbOmUuOH TgWrI3fphEZmPyk2HQ1MWpm3Jxhp+K6/492Y3YYF2pUncbLVc2luOoVMZ617q9p7ghDvoA0bhZbs1 TiViZQXLnif6cgUSh9zmV0hF/PZBOrEL39AHjeWhU11FNbJJvjOiyXq6Tqi/ySNC3f6bOIw7g97TY ad9lF/izArY+e3W4BANjIltdFC2A9idu7pkIpZbMTVVBFUweb8ZnUOU4T+N+k7eB78p+ew2WcPwRh IfDhJgpIIsuEvmptELWiVtHyBEdRpPIaL0Wh7x4jxDW9u8ym9o9bJQ5STeILHtO0j9wgnDsLf3N+l iC7ZIkCQ==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 03/11] Add support for django-filter 1.1 Date: Sun, 24 Jun 2018 20:55:49 +0100 Message-Id: <20180624195557.19909-3-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180624195557.19909-1-stephen@that.guru> References: <20180624195557.19909-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" There's one warning to handle here. Signed-off-by: Stephen Finucane --- README.rst | 2 +- patchwork/api/filters.py | 5 +++-- patchwork/compat.py | 17 +++++++++++++++++ .../django-filter-1-1-6a6b0ab8cbe0faca.yaml | 6 ++++++ requirements-dev.txt | 2 +- requirements-prod.txt | 2 +- tox.ini | 3 ++- 7 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml diff --git a/README.rst b/README.rst index ddc4b981..94ac32c3 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,7 @@ Requirements - Django REST Framework (3.4 - 3.8) -- Django Filters (1.0) +- Django Filters (1.0 - 1.1) Development Installation ------------------------ diff --git a/patchwork/api/filters.py b/patchwork/api/filters.py index 73353d90..ddf527fd 100644 --- a/patchwork/api/filters.py +++ b/patchwork/api/filters.py @@ -26,6 +26,7 @@ from django_filters import ModelMultipleChoiceFilter from django.forms import ModelMultipleChoiceField as BaseMultipleChoiceField from django.forms.widgets import MultipleHiddenInput +from patchwork.compat import NAME_FIELD from patchwork.models import Bundle from patchwork.models import Check from patchwork.models import CoverLetter @@ -151,8 +152,8 @@ class UserFilter(ModelMultipleChoiceFilter): class TimestampMixin(FilterSet): # TODO(stephenfin): These should filter on a 'updated_at' field instead - before = IsoDateTimeFilter(name='date', lookup_expr='lt') - since = IsoDateTimeFilter(name='date', lookup_expr='gte') + before = IsoDateTimeFilter(lookup_expr='lt', **{NAME_FIELD: 'date'}) + since = IsoDateTimeFilter(lookup_expr='gte', **{NAME_FIELD: 'date'}) class SeriesFilterSet(TimestampMixin, FilterSet): diff --git a/patchwork/compat.py b/patchwork/compat.py index 38caa4e8..e74e9264 100644 --- a/patchwork/compat.py +++ b/patchwork/compat.py @@ -41,6 +41,23 @@ if settings.ENABLE_REST_API: from rest_framework.filters import DjangoFilterBackend # noqa +# NAME_FIELD +# +# The django-filter library renamed 'Filter.name' to 'Filter.field_name' in +# 1.1. +# +# https://django-filter.readthedocs.io/en/master/guide/migration.html\ +# #migrating-to-2-0 + +if settings.ENABLE_REST_API: + import django_filters # noqa + + if django_filters.VERSION >= (1, 1): + NAME_FIELD = 'field_name' + else: + NAME_FIELD = 'name' + + # reverse, reverse_lazy # # The reverse and reverse_lazy functions have been moved to django.urls in diff --git a/releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml b/releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml new file mode 100644 index 00000000..3beb9c08 --- /dev/null +++ b/releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + `django-filter 1.1 + `_ is + now supported. diff --git a/requirements-dev.txt b/requirements-dev.txt index b12246dd..1d58df71 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ Django>=1.8,<2.0 djangorestframework>=3.4,<3.9 -django-filter>=1.0,<1.1 +django-filter>=1.0,<1.2 -r requirements-test.txt diff --git a/requirements-prod.txt b/requirements-prod.txt index 42ff8ecd..59e2c1e6 100644 --- a/requirements-prod.txt +++ b/requirements-prod.txt @@ -1,5 +1,5 @@ Django>=1.8,<2.0 djangorestframework>=3.4,<3.9 -django-filter>=1.0,<1.1 +django-filter>=1.0,<1.2 psycopg2>=2.7,<2.8 sqlparse==0.2.4 diff --git a/tox.ini b/tox.ini index c1bc64e3..9aac8247 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,8 @@ deps = django{18,19}: djangorestframework>=3.4,<3.7 django110: djangorestframework>=3.4,<3.9 django111: djangorestframework>=3.6,<3.9 - django{18,19,110,111}: django-filter>=1.0,<1.1 + django18: django-filter>=1.0,<1.1 + django{19,110,111}: django-filter>=1.0,<1.2 setenv = DJANGO_SETTINGS_MODULE = patchwork.settings.dev PYTHONDONTWRITEBYTECODE = 1