From patchwork Sat Oct 29 13:13:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 688782 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 3t5h2M5ZGkz9t1H for ; Sun, 30 Oct 2016 00:15:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b=s9RQ/IXb; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3t5h2M4Tt2zDvRq for ; Sun, 30 Oct 2016 00:15:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b=s9RQ/IXb; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from bongo.tulip.relay.mailchannels.net (bongo.tulip.relay.mailchannels.net [23.83.218.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3t5h2C4VcYzDvV7 for ; Sun, 30 Oct 2016 00:15:30 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b=s9RQ/IXb; dkim-atps=neutral X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E98EBA1453 for ; Sat, 29 Oct 2016 13:15:23 +0000 (UTC) Received: from one.mxroute.com (ip-10-27-139-41.us-west-2.compute.internal [10.27.139.41]) by relay.mailchannels.net (Postfix) with ESMTPA id 72ECCA0B4F for ; Sat, 29 Oct 2016 13:15:23 +0000 (UTC) X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from one.mxroute.com ([UNAVAILABLE]. [10.28.138.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.7.8); Sat, 29 Oct 2016 13:15:23 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: mxroute|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: mxroute X-MC-Loop-Signature: 1477746923696:1690941247 X-MC-Ingress-Time: 1477746923695 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender: Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=1a52elz82O60yWdiT4FcsGwh1Ksi9OylN3w8lBTfmxQ=; b=s9RQ/IXbyyAHde+sLNmq4+ceEy ezCYcM/Otrs0SOCH4P3e4hjNnAx7Kh4c5lxGECQ75sf1jIrsOjOEp/v5l6ZEU0GSaO422pk5A99OZ QO7LxRxu1Tq0e4MbG+HxPwPotB5Xnd/Y1RNo1BotlZPL8sr7ZwKRQFXQWdupJzv+J9pgApCS0W9Yc pXm8SnJb1EswGUYu4q4NdV1Z7mL2mA74rG7PDQI5ClJunJaX4PG7tZmvzRymaAlQnzKtzzwju5Gvx dlYucXCF5bFGeue1Ocdf82rSSODkIOoDESlrf+87nikQdpsBYfyfnwbx/yn2EJ2DCs+WD4Ovwzlfr SPm2q8JA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v7 7/8] templates: Integrate series support Date: Sat, 29 Oct 2016 14:13:39 +0100 Message-Id: <1477746820-11629-8-git-send-email-stephen@that.guru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477746820-11629-1-git-send-email-stephen@that.guru> References: <1477746820-11629-1-git-send-email-stephen@that.guru> X-OutGoing-Spam-Status: No, score=-10.0 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.23 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" Integrate support for series in the web UI. This is rather straightforward, the only significant change being the addition of a filter for series filtering. Signed-off-by: Stephen Finucane Reviewed-by: Andy Doan Tested-by: Russell Currey Reviewed-by: Daniel Axtens Reviewed-by: Andrew Donnellan --- v7: - Reference 'Series' instead of 'SeriesRevision' - Remove unnecessary 'Exception' handler v5: - Don't use the 'Patch.series' property, which results in a new query each time v4: - Update to use newly added Series.name field --- patchwork/filters.py | 49 +++++++++++++++++++++++++-- patchwork/templates/patchwork/patch-list.html | 13 +++++++ patchwork/views/__init__.py | 4 +-- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/patchwork/filters.py b/patchwork/filters.py index ea832b7..bc8ca41 100644 --- a/patchwork/filters.py +++ b/patchwork/filters.py @@ -25,7 +25,9 @@ from django.utils.safestring import mark_safe from django.utils import six from django.utils.six.moves.urllib.parse import quote -from patchwork.models import Person, State +from patchwork.models import Person +from patchwork.models import Series +from patchwork.models import State class Filter(object): @@ -82,6 +84,48 @@ class Filter(object): return '%s: %s' % (self.name, self.kwargs()) +class SeriesFilter(Filter): + param = 'series' + name = 'Series' + + def __init__(self, filters): + super(SeriesFilter, self).__init__(filters) + self.series = None + + def _set_key(self, key): + self.series = None + + key = key.strip() + if not key: + return + + try: + self.series = Series.objects.get(id=int(key)) + except (ValueError, Series.DoesNotExist): + return + + self.applied = True + + def kwargs(self): + if self.series: + return {'series': self.series} + return {} + + def condition(self): + if self.series: + return self.series.name + return '' + + def _form(self): + return mark_safe(('')) + + def key(self): + if self.series: + return self.series.id + return + + class SubmitterFilter(Filter): param = 'submitter' @@ -391,7 +435,8 @@ class DelegateFilter(Filter): self.forced = True -filterclasses = [SubmitterFilter, +filterclasses = [SeriesFilter, + SubmitterFilter, StateFilter, SearchFilter, ArchiveFilter, diff --git a/patchwork/templates/patchwork/patch-list.html b/patchwork/templates/patchwork/patch-list.html index 937a609..4b979ac 100644 --- a/patchwork/templates/patchwork/patch-list.html +++ b/patchwork/templates/patchwork/patch-list.html @@ -83,6 +83,10 @@ $(document).ready(function() { + Series + + + {% project_tags %} @@ -176,6 +180,15 @@ $(document).ready(function() { {{ patch.name|default:"[no subject]"|truncatechars:100 }} + + {% with patch.series.all.0 as series %} + {% if series %} + + {{ series|truncatechars:100 }} + + {% endif %} + {% endwith %} + {{ patch|patch_tags }} {{ patch|patch_checks }} {{ patch.date|date:"Y-m-d" }} diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index 8b5e881..a29da83 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -297,8 +297,8 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, # rendering the list template patches = patches.select_related('state', 'submitter', 'delegate') - # we also need checks - patches = patches.prefetch_related('check_set') + # we also need checks and series + patches = patches.prefetch_related('check_set', 'series') paginator = Paginator(request, patches)