From f8cc68d3a0c77906b9d1914f4b78a80b7b3f09db Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Sun, 10 Jan 2016 15:26:37 +0000 Subject: [PATCH] templates: Cleanup patch-list 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 25287900..66149c3b 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 00000000..689b4860 --- /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]))) -- 2.47.3