From patchwork Wed Feb 3 21:31:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 578395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A0B581402DE for ; Thu, 4 Feb 2016 08:33:37 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 831021A02AF for ; Thu, 4 Feb 2016 08:33:37 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lists.ozlabs.org (Postfix) with ESMTP id 59EBA1A026C for ; Thu, 4 Feb 2016 08:32:01 +1100 (AEDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 03 Feb 2016 13:32:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,391,1449561600"; d="scan'208,217";a="876394752" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 03 Feb 2016 13:31:59 -0800 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 u13LVwH3029213; Wed, 3 Feb 2016 21:31:58 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u13LVwn6019078; Wed, 3 Feb 2016 21:31:58 GMT Received: (from sfinucan@localhost) by sivswdev01.ir.intel.com with id u13LVwRO019074; Wed, 3 Feb 2016 21:31:58 GMT From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 19/19] templates: Cleanup patch-list Date: Wed, 3 Feb 2016 21:31:54 +0000 Message-Id: <1454535114-18190-20-git-send-email-stephen.finucane@intel.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1454535114-18190-1-git-send-email-stephen.finucane@intel.com> References: <1454535114-18190-1-git-send-email-stephen.finucane@intel.com> 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: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Cleanup this file before doing any work on it. Items addressed: * Move complex logic into template tags * Move related content closer together * Random whitespace annoyances Signed-off-by: Stephen Finucane --- patchwork/templates/patchwork/patch-list.html | 95 +++++++++++++++------------ patchwork/templatetags/project.py | 33 ++++++++++ 2 files changed, 85 insertions(+), 43 deletions(-) create mode 100644 patchwork/templatetags/project.py diff --git a/patchwork/templates/patchwork/patch-list.html b/patchwork/templates/patchwork/patch-list.html index 2528790..66149c3 100644 --- a/patchwork/templates/patchwork/patch-list.html +++ b/patchwork/templates/patchwork/patch-list.html @@ -1,6 +1,7 @@ {% load person %} {% load listurl %} {% load patch %} +{% load project %} {% load static %} {% load cycle from future %} @@ -30,8 +31,9 @@ {% if page.paginator.long_page and user.is_authenticated %} {% endif %} @@ -55,11 +57,12 @@ $(document).ready(function() { {% ifequal order.name "name" %} - Patch + + + + + Patch + {% else %} {% if not order.editable %} Patch @@ -70,9 +73,7 @@ $(document).ready(function() { - {% for tag in project.tags %}{{tag.abbrev}}{% if not forloop.last %}/{% endif %}{% endfor %} + {% project_tags %} @@ -81,11 +82,12 @@ $(document).ready(function() { {% ifequal order.name "date" %} - Date + + + + + Date + {% else %} {% if not order.editable %} Date @@ -97,14 +99,17 @@ $(document).ready(function() { {% ifequal order.name "submitter" %} - Submitter + + + + + Submitter + {% else %} {% if not order.editable %} - Submitter + + Submitter + {% else %} Submitter {% endif %} @@ -113,11 +118,12 @@ $(document).ready(function() { {% ifequal order.name "delegate" %} - Delegate + + + + + Delegate + {% else %} {% if not order.editable %} Delegate @@ -129,11 +135,12 @@ $(document).ready(function() { {% ifequal order.name "state" %} - State + + + + + State + {% else %} {% if not order.editable %} State @@ -146,17 +153,19 @@ $(document).ready(function() { -{% if page.paginator.count %} {% for patch in page.object_list %} - {% if user.is_authenticated %} - + {% if user.is_authenticated %} + - - {% endif %} - {{ patch.name|default:"[no subject]"|truncatechars:100 }} + + {% endif %} + + + {{ patch.name|default:"[no subject]"|truncatechars:100 }} + + {{ patch|patch_tags }} {{ patch|patch_checks }} {{ patch.date|date:"Y-m-d" }} @@ -164,10 +173,15 @@ $(document).ready(function() { {{ patch.delegate.username }} {{ patch.state }} + {% empty %} + + No patches to display + {% endfor %} +{% if page.paginator.count %} {% include "patchwork/pagination.html" %}
@@ -245,15 +259,10 @@ $(document).ready(function() {
{% endif %} -
-{% else %} - - No patches to display - {% endif %} diff --git a/patchwork/templatetags/project.py b/patchwork/templatetags/project.py new file mode 100644 index 0000000..689b486 --- /dev/null +++ b/patchwork/templatetags/project.py @@ -0,0 +1,33 @@ +# Patchwork - automated patch tracking system +# Copyright (C) 2016 Intel Corporation +# +# 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 __future__ import absolute_import + +from django import template +from django.utils.safestring import mark_safe + + +register = template.Library() + + +@register.simple_tag(takes_context=True) +def project_tags(context): + return mark_safe('%s' % ( + ' / '.join([tag.name for tag in context['project'].tags]), + '/'.join([tag.abbrev for tag in context['project'].tags])))