From patchwork Mon Jun 13 10:41: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: 634512 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 3rSq9b20G2z9snl for ; Mon, 13 Jun 2016 20:42:43 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rSq9b0lkMzDqc8 for ; Mon, 13 Jun 2016 20:42:43 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lists.ozlabs.org (Postfix) with ESMTP id 3rSq8c3z4pzDqZc for ; Mon, 13 Jun 2016 20:41:52 +1000 (AEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 13 Jun 2016 03:41:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,466,1459839600"; d="scan'208";a="718202409" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 13 Jun 2016 03:41:48 -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 u5DAfmul001477; Mon, 13 Jun 2016 11:41:48 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u5DAflaG016897; Mon, 13 Jun 2016 11:41:47 +0100 Received: (from sfinucan@localhost) by sivswdev01.ir.intel.com with id u5DAflKp016893; Mon, 13 Jun 2016 11:41:47 +0100 From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 07/10] templates: Integrate series support Date: Mon, 13 Jun 2016 11:41:39 +0100 Message-Id: <1465814502-14108-8-git-send-email-stephen.finucane@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1465814502-14108-1-git-send-email-stephen.finucane@intel.com> References: <1465814502-14108-1-git-send-email-stephen.finucane@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.22 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 --- patchwork/filters.py | 56 ++++++++++++++++++++++++- patchwork/templates/patchwork/patch-list.html | 12 +++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/patchwork/filters.py b/patchwork/filters.py index 5650014..264ef24 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 SeriesRevision +from patchwork.models import State class Filter(object): @@ -80,6 +82,55 @@ 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 + series_id = None + + key = key.strip() + if not key: + return + + try: + series_id = int(key) + except ValueError: + pass + except Exception: + return + + if not series_id: + return + + self.series = SeriesRevision.objects.get(id=series_id) + 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' @@ -399,7 +450,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 b7648d3..0050ab0 100644 --- a/patchwork/templates/patchwork/patch-list.html +++ b/patchwork/templates/patchwork/patch-list.html @@ -83,6 +83,11 @@ $(document).ready(function() { + + Series + + + {% project_tags %} @@ -176,6 +181,13 @@ $(document).ready(function() { {{ patch.name|default:"[no subject]"|truncatechars:100 }} + + {% if patch.series %} + + {{ patch.series.name|truncatechars:100 }} + + {% endif %} + {{ patch|patch_tags }} {{ patch|patch_checks }} {{ patch.date|date:"Y-m-d" }}