[PATCH 1/5] templates: Replace ifequal and ifnotequal with if

2020-08-27 Thread Andrew Donnellan
Django 3.1 deprecates the ifequal and ifnotequal tags, for removal in 4.0.
Replace all occurrences of ifequal and ifnotequal with if.

Signed-off-by: Andrew Donnellan 
---
 .../patchwork/partials/pagination.html|  8 
 .../patchwork/partials/patch-list.html| 20 +--
 patchwork/templates/patchwork/profile.html|  4 ++--
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/patchwork/templates/patchwork/partials/pagination.html 
b/patchwork/templates/patchwork/partials/pagination.html
index 04f4d16671c2..ee4b555d62c2 100644
--- a/patchwork/templates/patchwork/partials/pagination.html
+++ b/patchwork/templates/patchwork/partials/pagination.html
@@ -1,6 +1,6 @@
 {% load listurl %}
 
-{% ifnotequal page.paginator.num_pages 1 %}
+{% if page.paginator.num_pages != 1 %}
 
 {% if page.has_previous %}
  
@@ -18,12 +18,12 @@
 {% endif %}
 
 {% for p in page.paginator.adjacent_set %}
-  {% ifequal p page.number %}
+  {% if p == page.number %}
 {{ p }}
   {% else %}
 {{ p }}
-  {% endifequal %}
+  {% endif %}
 {% endfor %}
 
 {% if page.paginator.leading_set %}
@@ -42,4 +42,4 @@
  
 {% endif %}
 
-{% endifnotequal %}
+{% endif %}
diff --git a/patchwork/templates/patchwork/partials/patch-list.html 
b/patchwork/templates/patchwork/partials/patch-list.html
index 985e9bee05a0..02d6dff87c97 100644
--- a/patchwork/templates/patchwork/partials/patch-list.html
+++ b/patchwork/templates/patchwork/partials/patch-list.html
@@ -71,7 +71,7 @@ $(document).ready(function() {
{% endif %}
 

-{% ifequal order.name "name" %}
+{% if order.name == "name" %}
  
   
  
@@ -84,7 +84,7 @@ $(document).ready(function() {
  {% else %}
  Patch
  {% endif %}
-{% endifequal %}
+{% endif %}

 

@@ -100,7 +100,7 @@ $(document).ready(function() {

 

-{% ifequal order.name "date" %}
+{% if order.name == "date" %}
  
   
  
@@ -113,11 +113,11 @@ $(document).ready(function() {
  {% else %}
  Date
  {% endif %}
-{% endifequal %}
+{% endif %}

 

-{% ifequal order.name "submitter" %}
+{% if order.name == "submitter" %}
  
   
  
@@ -132,11 +132,11 @@ $(document).ready(function() {
  {% else %}
  Submitter
  {% endif %}
-{% endifequal %}
+{% endif %}

 

-{% ifequal order.name "delegate" %}
+{% if order.name == "delegate" %}
  
   
  
@@ -149,11 +149,11 @@ $(document).ready(function() {
  {% else %}
  Delegate
  {% endif %}
-{% endifequal %}
+{% endif %}

 

-{% ifequal order.name "state" %}
+{% if order.name == "state" %}
  
   
  
@@ -166,7 +166,7 @@ $(document).ready(function() {
  {% else %}
  State
  {% endif %}
-{% endifequal %}
+{% endif %}

 
   
diff --git a/patchwork/templates/patchwork/profile.html 
b/patchwork/templates/patchwork/profile.html
index 4ca78dae430e..4a4b55826d03 100644
--- a/patchwork/templates/patchwork/profile.html
+++ b/patchwork/templates/patchwork/profile.html
@@ -55,13 +55,13 @@ address.
  
   {{ email.email }}
   
-  {% ifnotequal user.email email.email %}
+  {% if user.email != email.email %}

 {% csrf_token %}
 

-{% endifnotequal %}
+{% endif %}
   
   
{% if email.is_optout %}
-- 
2.20.1

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


[PATCH 2/5] urls: Update url pattern functions

2020-08-27 Thread Andrew Donnellan
Django 3.1 deprecates django.conf.urls.url() as an alias for
django.urls.re_path(). Also switch to using django.urls.include() rather
than django.conf.urls.include().

Signed-off-by: Andrew Donnellan 
---
 patchwork/urls.py | 331 +++---
 1 file changed, 167 insertions(+), 164 deletions(-)

diff --git a/patchwork/urls.py b/patchwork/urls.py
index 7d888d4a3dc0..280d28d8e5bd 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -4,10 +4,9 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
 from django.conf import settings
-from django.conf.urls import url, include
 from django.contrib import admin
 from django.contrib.auth import views as auth_views
-from django.urls import reverse_lazy
+from django.urls import include, re_path, reverse_lazy
 
 from patchwork.views import about as about_views
 from patchwork.views import api as api_views
@@ -27,15 +26,16 @@ from patchwork.views import xmlrpc as xmlrpc_views
 admin.autodiscover()
 
 urlpatterns = [
-url(r'^admin/', admin.site.urls),
+re_path(r'^admin/', admin.site.urls),
 
-url(r'^$', project_views.project_list, name='project-list'),
-url(r'^project/(?P[^/]+)/list/$', patch_views.patch_list,
-name='patch-list'),
-url(r'^project/(?P[^/]+)/bundles/$', bundle_views.bundle_list,
-name='bundle-list'),
-url(r'^project/(?P[^/]+)/$', project_views.project_detail,
-name='project-detail'),
+re_path(r'^$', project_views.project_list, name='project-list'),
+re_path(r'^project/(?P[^/]+)/list/$', patch_views.patch_list,
+name='patch-list'),
+re_path(r'^project/(?P[^/]+)/bundles/$',
+bundle_views.bundle_list,
+name='bundle-list'),
+re_path(r'^project/(?P[^/]+)/$', project_views.project_detail,
+name='project-detail'),
 
 # patch views
 # NOTE(dja): Per the RFC, msgids can contain slashes. There doesn't seem
@@ -49,128 +49,129 @@ urlpatterns = [
 # work, but it is RECOMMENDED by the RFC that the right hand side of the @
 # contains a domain, so I think breaking on messages that have "domains"
 # ending in /raw/ or /mbox/ is good enough.
-url(r'^project/(?P[^/]+)/patch/(?P.+)/raw/$',
-patch_views.patch_raw, name='patch-raw'),
-url(r'^project/(?P[^/]+)/patch/(?P.+)/mbox/$',
-patch_views.patch_mbox, name='patch-mbox'),
-url(r'^project/(?P[^/]+)/patch/(?P.+)/$',
-patch_views.patch_detail, name='patch-detail'),
+re_path(r'^project/(?P[^/]+)/patch/(?P.+)/raw/$',
+patch_views.patch_raw, name='patch-raw'),
+re_path(r'^project/(?P[^/]+)/patch/(?P.+)/mbox/$',
+patch_views.patch_mbox, name='patch-mbox'),
+re_path(r'^project/(?P[^/]+)/patch/(?P.+)/$',
+patch_views.patch_detail, name='patch-detail'),
 # ... old-style /patch/N/* urls
-url(r'^patch/(?P\d+)/raw/$', patch_views.patch_raw_by_id,
-name='patch-raw-redirect'),
-url(r'^patch/(?P\d+)/mbox/$', patch_views.patch_mbox_by_id,
-name='patch-mbox-redirect'),
-url(r'^patch/(?P\d+)/$', patch_views.patch_by_id,
-name='patch-id-redirect'),
+re_path(r'^patch/(?P\d+)/raw/$', patch_views.patch_raw_by_id,
+name='patch-raw-redirect'),
+re_path(r'^patch/(?P\d+)/mbox/$', patch_views.patch_mbox_by_id,
+name='patch-mbox-redirect'),
+re_path(r'^patch/(?P\d+)/$', patch_views.patch_by_id,
+name='patch-id-redirect'),
 
 # cover views
-url(r'^project/(?P[^/]+)/cover/(?P.+)/mbox/$',
-cover_views.cover_mbox, name='cover-mbox'),
-url(r'^project/(?P[^/]+)/cover/(?P.+)/$',
-cover_views.cover_detail, name='cover-detail'),
+re_path(r'^project/(?P[^/]+)/cover/(?P.+)/mbox/$',
+cover_views.cover_mbox, name='cover-mbox'),
+re_path(r'^project/(?P[^/]+)/cover/(?P.+)/$',
+cover_views.cover_detail, name='cover-detail'),
 # ... old-style /cover/N/* urls
-url(r'^cover/(?P\d+)/mbox/$', cover_views.cover_mbox_by_id,
-name='cover-mbox-redirect'),
-url(r'^cover/(?P\d+)/$', cover_views.cover_by_id,
-name='cover-id-redirect'),
+re_path(r'^cover/(?P\d+)/mbox/$', cover_views.cover_mbox_by_id,
+name='cover-mbox-redirect'),
+re_path(r'^cover/(?P\d+)/$', cover_views.cover_by_id,
+name='cover-id-redirect'),
 
 # comment views
-url(r'^comment/(?P\d+)/$', comment_views.comment,
-name='comment-redirect'),
+re_path(r'^comment/(?P\d+)/$', comment_views.comment,
+name='comment-redirect'),
 
 # series views
-url(r'^series/(?P\d+)/mbox/$', series_views.series_mbox,
-name='series-mbox'),
+re_path(r'^series/(?P\d+)/mbox/$', series_views.series_mbox,
+name='series-mbox'),
 
 # logged-in user stuff
-url(r'^user/$', user_views.profile, name='user-profile'),
-url(r'^user/todo/$', user_views.todo_lists,
-name='user-todos'),
-

[PATCH 3/5] settings: Add context processor django.template.context_processors.request

2020-08-27 Thread Andrew Donnellan
Django 3.1 adds a new admin sidebar feature that requires the
django.template.context_processors.request context processor to be enabled
in the settings.

Signed-off-by: Andrew Donnellan 
---
 patchwork/settings/base.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index 001878acb134..c1bb9b27fac8 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -57,6 +57,7 @@ TEMPLATES = [
 'django.template.context_processors.debug',
 'django.template.context_processors.i18n',
 'django.template.context_processors.media',
+'django.template.context_processors.request',
 'django.template.context_processors.static',
 'django.template.context_processors.tz',
 'django.contrib.messages.context_processors.messages',
-- 
2.20.1

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


[PATCH 5/5] Add support for Django 3.1

2020-08-27 Thread Andrew Donnellan
Signed-off-by: Andrew Donnellan 
---
 releasenotes/notes/django-3-1-support-f0450ed3e7983fe2.yaml | 5 +
 requirements-dev.txt| 2 +-
 requirements-prod.txt   | 2 +-
 tox.ini | 5 -
 4 files changed, 11 insertions(+), 3 deletions(-)
 create mode 100644 releasenotes/notes/django-3-1-support-f0450ed3e7983fe2.yaml

diff --git a/releasenotes/notes/django-3-1-support-f0450ed3e7983fe2.yaml 
b/releasenotes/notes/django-3-1-support-f0450ed3e7983fe2.yaml
new file mode 100644
index ..dff8af13a846
--- /dev/null
+++ b/releasenotes/notes/django-3-1-support-f0450ed3e7983fe2.yaml
@@ -0,0 +1,5 @@
+---
+features:
+  - |
+`Django 3.1 `_ is
+now supported.
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 022f465deee5..ce306cf3761d 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,4 +1,4 @@
-Django~=3.0.0
+Django~=3.1.0
 djangorestframework~=3.11.0
 django-filter~=2.3.0
 django-debug-toolbar~=2.2.0
diff --git a/requirements-prod.txt b/requirements-prod.txt
index dc86ce0c042f..b7ca00b59310 100644
--- a/requirements-prod.txt
+++ b/requirements-prod.txt
@@ -1,4 +1,4 @@
-Django~=3.0.0
+Django~=3.1.0
 djangorestframework~=3.11.0
 django-filter~=2.3.0
 psycopg2-binary~=2.8.0
diff --git a/tox.ini b/tox.ini
index 0e4c78fbff2f..80b43a600bad 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 minversion = 3.2
-envlist = pep8,docs,py{36,37,38}-django{22,30}
+envlist = pep8,docs,py{36,37,38}-django{22,30,31}
 skipsdist = true
 ignore_basepython_conflict = true
 
@@ -14,6 +14,9 @@ deps =
 django30: django>=3.0,<3.1
 django30: djangorestframework>=3.10,<3.12
 django30: django-filter>=2.2,<3.0
+django31: django>=3.1,<3.2
+django31: djangorestframework>=3.10,<3.12
+django31: django-filter>=2.3,<3.0
 setenv =
 DJANGO_SETTINGS_MODULE = patchwork.settings.dev
 PYTHONDONTWRITEBYTECODE = 1
-- 
2.20.1

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


[PATCH 4/5] requirements: Update django-filter

2020-08-27 Thread Andrew Donnellan
Update django-filter dependency to a version that's compatible with Django
3.1.

Signed-off-by: Andrew Donnellan 
---
 requirements-dev.txt  | 2 +-
 requirements-prod.txt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/requirements-dev.txt b/requirements-dev.txt
index e5da0b831fd6..022f465deee5 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,6 +1,6 @@
 Django~=3.0.0
 djangorestframework~=3.11.0
-django-filter~=2.2.0
+django-filter~=2.3.0
 django-debug-toolbar~=2.2.0
 # django-dbbackup~=3.2.0
 -r requirements-test.txt
diff --git a/requirements-prod.txt b/requirements-prod.txt
index dbd0bd543cf8..dc86ce0c042f 100644
--- a/requirements-prod.txt
+++ b/requirements-prod.txt
@@ -1,5 +1,5 @@
 Django~=3.0.0
 djangorestframework~=3.11.0
-django-filter~=2.2.0
+django-filter~=2.3.0
 psycopg2-binary~=2.8.0
 sqlparse~=0.3.0
-- 
2.20.1

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork