[PATCH 2/5] templates: Resolve cycle issues with Django 1.10
Stephen Finucane
stephen at that.guru
Mon Oct 10 06:25:40 AEDT 2016
The 'future.cycle' template tag is removed in Django 1.10. Since
Django 1.7 is still supported by Patchwork, it is necessary to
provide a custom 'cycle' wrapper to prevent the deprecation
warnings resolved by '9cab078' being reintroduced.
Signed-off-by: Stephen Finucane <stephen at that.guru>
---
patchwork/templates/patchwork/patch-list.html | 2 +-
patchwork/templatetags/compat.py | 44 +++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)
create mode 100644 patchwork/templatetags/compat.py
diff --git a/patchwork/templates/patchwork/patch-list.html b/patchwork/templates/patchwork/patch-list.html
index b7648d3..937a609 100644
--- a/patchwork/templates/patchwork/patch-list.html
+++ b/patchwork/templates/patchwork/patch-list.html
@@ -4,7 +4,7 @@
{% load project %}
{% load static %}
-{% load cycle from future %}
+{% load cycle from compat %}
{% include "patchwork/filters.html" %}
diff --git a/patchwork/templatetags/compat.py b/patchwork/templatetags/compat.py
new file mode 100644
index 0000000..4b7e8d2
--- /dev/null
+++ b/patchwork/templatetags/compat.py
@@ -0,0 +1,44 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2016 Stephen Finucane <stephenfinucane at hotmail.com>
+#
+# This file is part of the Patchwork package.
+#
+# Patchwork is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Patchwork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Patchwork; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Compatibility wrappers for various Django versions."""
+
+import django
+from django.template import defaulttags
+from django.template import Library
+
+
+register = Library()
+
+# cycle
+#
+# The cycle template tag enables auto-escaping by default in 1.8, with
+# deprecations enabled in 1.7. A 'future' library is provided in 1.6
+# to mitigate this, but it is removed in 1.10. Provide our own version
+# of 'future' to ensure this works in all versions of Django supported.
+#
+# https://docs.djangoproject.com/en/dev/releases/1.6/
+# https://docs.djangoproject.com/en/dev/releases/1.10/
+
+ at register.tag
+def cycle(parser, token):
+ if django.VERSION < (1, 8):
+ return defaulttags.cycle(parser, token, escape=True)
+ else:
+ return defaulttags.cycle(parser, token)
--
2.7.4
More information about the Patchwork
mailing list