From patchwork Mon Jun 29 13:46:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 489592 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D283A1402C4 for ; Tue, 30 Jun 2015 18:53:10 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id B7B771A2AC0 for ; Tue, 30 Jun 2015 18:53:10 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lists.ozlabs.org (Postfix) with ESMTP id A2BCA1A009B for ; Mon, 29 Jun 2015 23:46:56 +1000 (AEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 29 Jun 2015 06:46:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,698,1427785200"; d="scan'208";a="596723527" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 29 Jun 2015 06:46:27 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t5TDkQXS018086; Mon, 29 Jun 2015 14:46:26 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t5TDkQF7030592; Mon, 29 Jun 2015 14:46:26 +0100 Received: (from sfinucan@localhost) by sivswdev01.ir.intel.com with id t5TDkQYC030586; Mon, 29 Jun 2015 14:46:26 +0100 From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 04/11] trivial: Remove dead files from 'templatetags' Date: Mon, 29 Jun 2015 14:46:04 +0100 Message-Id: <1435585571-25252-5-git-send-email-stephen.finucane@intel.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1435585571-25252-1-git-send-email-stephen.finucane@intel.com> References: <1435585571-25252-1-git-send-email-stephen.finucane@intel.com> X-Mailman-Approved-At: Tue, 30 Jun 2015 18:51:03 +1000 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Finucane MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Remove files that are no longer used, some of which contain issues that would render them useless. These unused files were initially discovered by using 'coverage.py' with both unit tests and a running instance of the server. Signed-off-by: Stephen Finucane --- patchwork/templatetags/filter.py | 36 ------------------- patchwork/templatetags/listurl.py | 71 ++++++++---------------------------- patchwork/templatetags/order.py | 66 ---------------------------------- patchwork/templatetags/patch.py | 46 ++---------------------- patchwork/templatetags/pwurl.py | 76 --------------------------------------- templates/base.html | 1 - 6 files changed, 16 insertions(+), 280 deletions(-) delete mode 100644 patchwork/templatetags/filter.py delete mode 100644 patchwork/templatetags/order.py delete mode 100644 patchwork/templatetags/pwurl.py diff --git a/patchwork/templatetags/filter.py b/patchwork/templatetags/filter.py deleted file mode 100644 index 7a5d9df..0000000 --- a/patchwork/templatetags/filter.py +++ /dev/null @@ -1,36 +0,0 @@ -# Patchwork - automated patch tracking system -# Copyright (C) 2008 Jeremy Kerr -# -# 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 - -from django import template -from django.utils.html import escape - -import re - - -register = template.Library() - -@register.filter -def personify(person): - if person.name: - linktext = escape(person.name) - else: - linktext = escape(person.email) - - return '%s' % (escape(person.email), linktext) - diff --git a/patchwork/templatetags/listurl.py b/patchwork/templatetags/listurl.py index 5fe03e4..a52f4fd 100644 --- a/patchwork/templatetags/listurl.py +++ b/patchwork/templatetags/listurl.py @@ -19,19 +19,19 @@ from django import template from django.utils.html import escape -from django.utils.safestring import mark_safe from django.utils.encoding import smart_str from patchwork.filters import filterclasses from django.conf import settings from django.core.urlresolvers import reverse, NoReverseMatch -import re register = template.Library() # params to preserve across views -list_params = [ c.param for c in filterclasses ] + ['order', 'page'] +list_params = [c.param for c in filterclasses] + ['order', 'page'] + class ListURLNode(template.defaulttags.URLNode): + def __init__(self, kwargs): super(ListURLNode, self).__init__(None, [], {}, False) self.params = {} @@ -41,8 +41,7 @@ class ListURLNode(template.defaulttags.URLNode): def render(self, context): view_name = template.Variable('list_view.view').resolve(context) - kwargs = template.Variable('list_view.view_params') \ - .resolve(context) + kwargs = template.Variable('list_view.view_params').resolve(context) str = None try: @@ -51,10 +50,10 @@ class ListURLNode(template.defaulttags.URLNode): try: project_name = settings.SETTINGS_MODULE.split('.')[0] str = reverse(project_name + '.' + view_name, - args=[], kwargs=kwargs) + args=[], kwargs=kwargs) except NoReverseMatch: raise - + if str is None: return '' @@ -66,20 +65,21 @@ class ListURLNode(template.defaulttags.URLNode): pass for (k, v) in self.params.iteritems(): - params[smart_str(k,'ascii')] = v.resolve(context) + params[smart_str(k, 'ascii')] = v.resolve(context) if not params: return str - return str + '?' + '&'.join(['%s=%s' % (k, escape(v)) \ - for (k, v) in params.iteritems()]) + return str + '?' + '&'.join( + ['%s=%s' % (k, escape(v)) for (k, v) in params.iteritems()]) + @register.tag def listurl(parser, token): bits = token.contents.split(' ', 1) if len(bits) < 1: - raise TemplateSyntaxError("'%s' takes at least one argument" - " (path to a view)" % bits[0]) + raise template.TemplateSyntaxError( + "'%s' takes at least one argument (path to a view)" % bits[0]) kwargs = {} if len(bits) > 1: for arg in bits[1].split(','): @@ -88,49 +88,6 @@ def listurl(parser, token): k = k.strip() kwargs[k] = parser.compile_filter(v) else: - raise TemplateSyntaxError("'%s' requires name=value params" \ - % bits[0]) + raise template.TemplateSyntaxError( + "'%s' requires name=value params" % bits[0]) return ListURLNode(kwargs) - -class ListFieldsNode(template.Node): - def __init__(self, params): - self.params = params - - def render(self, context): - self.view_name = template.Variable('list_view.view').resolve(context) - try: - qs_var = template.Variable('list_view.params') - params = dict(qs_var.resolve(context)) - except Exception: - pass - - params.update(self.params) - - if not params: - return '' - - str = '' - for (k, v) in params.iteritems(): - str += '' % \ - (k, escape(v)) - - return mark_safe(str) - -@register.tag -def listfields(parser, token): - bits = token.contents.split(' ', 1) - if len(bits) < 1: - raise TemplateSyntaxError("'%s' takes at least one argument" - " (path to a view)" % bits[0]) - params = {} - if len(bits) > 2: - for arg in bits[2].split(','): - if '=' in arg: - k, v = arg.split('=', 1) - k = k.strip() - params[k] = parser.compile_filter(v) - else: - raise TemplateSyntaxError("'%s' requires name=value params" \ - % bits[0]) - return ListFieldsNode(bits[1], params) - diff --git a/patchwork/templatetags/order.py b/patchwork/templatetags/order.py deleted file mode 100644 index e392f03..0000000 --- a/patchwork/templatetags/order.py +++ /dev/null @@ -1,66 +0,0 @@ -# Patchwork - automated patch tracking system -# Copyright (C) 2008 Jeremy Kerr -# -# 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 - - -from django import template -import re - -register = template.Library() - -@register.tag(name = 'ifpatcheditable') -def do_patch_is_editable(parser, token): - try: - tag_name, name, cur_order = token.split_contents() - except ValueError: - raise template.TemplateSyntaxError("%r tag requires two arguments" \ - % token.contents.split()[0]) - - end_tag = 'endifpatcheditable' - nodelist_true = parser.parse([end_tag, 'else']) - - token = parser.next_token() - if token.contents == 'else': - nodelist_false = parser.parse([end_tag]) - parser.delete_first_token() - else: - nodelist_false = template.NodeList() - - return EditablePatchNode(patch_var, nodelist_true, nodelist_false) - -class EditablePatchNode(template.Node): - def __init__(self, patch_var, nodelist_true, nodelist_false): - self.nodelist_true = nodelist_true - self.nodelist_false = nodelist_false - self.patch_var = template.Variable(patch_var) - self.user_var = template.Variable('user') - - def render(self, context): - try: - patch = self.patch_var.resolve(context) - user = self.user_var.resolve(context) - except template.VariableDoesNotExist: - return '' - - if not user.is_authenticated(): - return self.nodelist_false.render(context) - - if not patch.is_editable(user): - return self.nodelist_false.render(context) - - return self.nodelist_true.render(context) diff --git a/patchwork/templatetags/patch.py b/patchwork/templatetags/patch.py index ea23ebd..496dcfc 100644 --- a/patchwork/templatetags/patch.py +++ b/patchwork/templatetags/patch.py @@ -19,51 +19,9 @@ from django import template from django.utils.safestring import mark_safe -import re register = template.Library() -@register.tag(name = 'ifpatcheditable') -def do_patch_is_editable(parser, token): - try: - tag_name, patch_var = token.split_contents() - except ValueError: - raise template.TemplateSyntaxError("%r tag requires one argument" \ - % token.contents.split()[0]) - - end_tag = 'endifpatcheditable' - nodelist_true = parser.parse([end_tag, 'else']) - - token = parser.next_token() - if token.contents == 'else': - nodelist_false = parser.parse([end_tag]) - parser.delete_first_token() - else: - nodelist_false = template.NodeList() - - return EditablePatchNode(patch_var, nodelist_true, nodelist_false) - -class EditablePatchNode(template.Node): - def __init__(self, patch_var, nodelist_true, nodelist_false): - self.nodelist_true = nodelist_true - self.nodelist_false = nodelist_false - self.patch_var = template.Variable(patch_var) - self.user_var = template.Variable('user') - - def render(self, context): - try: - patch = self.patch_var.resolve(context) - user = self.user_var.resolve(context) - except template.VariableDoesNotExist: - return '' - - if not user.is_authenticated(): - return self.nodelist_false.render(context) - - if not patch.is_editable(user): - return self.nodelist_false.render(context) - - return self.nodelist_true.render(context) @register.filter(name='patch_tags') def patch_tags(patch): @@ -74,5 +32,5 @@ def patch_tags(patch): titles.append('%d %s' % (count, tag.name)) counts.append(str(count)) return mark_safe('%s' % ( - ' / '.join(titles), - ' '.join(counts))) + ' / '.join(titles), + ' '.join(counts))) diff --git a/patchwork/templatetags/pwurl.py b/patchwork/templatetags/pwurl.py deleted file mode 100644 index 98bc1ca..0000000 --- a/patchwork/templatetags/pwurl.py +++ /dev/null @@ -1,76 +0,0 @@ -# Patchwork - automated patch tracking system -# Copyright (C) 2008 Jeremy Kerr -# -# 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 - -from django import template -from django.utils.html import escape -from django.utils.safestring import mark_safe -from patchwork.filters import filterclasses -import re - -register = template.Library() - -# params to preserve across views -list_params = [ c.param for c in filterclasses ] + ['order', 'page'] - -class ListURLNode(template.defaulttags.URLNode): - def __init__(self, *args, **kwargs): - super(ListURLNode, self).__init__(*args, **kwargs) - self.params = {} - for (k, v) in kwargs: - if k in list_params: - self.params[k] = v - - def render(self, context): - self.view_name = template.Variable('list_view.view') - str = super(ListURLNode, self).render(context) - if str == '': - return str - params = [] - try: - qs_var = template.Variable('list_view.params') - params = dict(qs_var.resolve(context)) - except Exception: - pass - - params.update(self.params) - - if not params: - return str - - return str + '?' + '&'.join(['%s=%s' % (k, escape(v)) \ - for (k, v) in params.iteritems()]) - -@register.tag -def listurl(parser, token): - bits = token.contents.split(' ', 1) - if len(bits) < 1: - raise TemplateSyntaxError("'%s' takes at least one argument" - " (path to a view)" % bits[0]) - args = [''] - kwargs = {} - if len(bits) > 1: - for arg in bits[2].split(','): - if '=' in arg: - k, v = arg.split('=', 1) - k = k.strip() - kwargs[k] = parser.compile_filter(v) - else: - args.append(parser.compile_filter(arg)) - return PatchworkURLNode(bits[1], args, kwargs) - diff --git a/templates/base.html b/templates/base.html index 3d289fb..c2053d4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,5 +1,4 @@ {% load staticfiles %} -{% load pwurl %}