From patchwork Sat Sep 29 21:26:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 976716 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42N1pZ51kWz9s1x for ; Sun, 30 Sep 2018 07:27:18 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="jqLrJE2O"; 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 42N1pZ2SJszF3Cm for ; Sun, 30 Sep 2018 07:27:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="jqLrJE2O"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.9; helo=relay002.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru 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="jqLrJE2O"; dkim-atps=neutral Received: from relay002.mxroute.com (relay002.mxroute.com [185.234.75.9]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42N1p30ynNzF3Cw for ; Sun, 30 Sep 2018 07:26:50 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay002.mxroute.com (Postfix) with ESMTP id 639263F2AB for ; Sat, 29 Sep 2018 21:26:17 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 4068E3F0F4 for ; Sat, 29 Sep 2018 21:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vUS/RkjgLwvvTKdgS+HZiioK+0nAyDoroJq4EjDfurk=; b=jqLrJE2ODQVQ6iPCtYQ+JgraHB TDbAGnmkZDHOQ0RhNpVLp4t1foujrlP/Uy1kbC/w9h/AkpVCMrHPLmM3k9JzUUlEbqVXXnXeykb7M 5b+Z4IYylOxmtD6qnrv5fSeHoSjFJa9EJwMY+5jESpxsPo6xq4tVzNqPYSepeVuy+xjgqGLMtINnG hz/Iwv8LQ7wrt2kav9aKNuLyScBiPQFe5E3eOdEYVbYgfHawr1Z9ZaK8q1470T6xzvmsAskmDHs8k ZaXhC2w0xDkxfH/jde0812ySx3I5uRVdKcx8bI4pAfgnPhN/LAT4h+Mll6uBP/PDXujgcfEoueQZO Ux884L9w==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v2 1/4] filters: Return dictionaries Date: Sat, 29 Sep 2018 22:26:07 +0100 Message-Id: <20180929212610.29905-1-stephen@that.guru> X-Mailer: git-send-email 2.17.1 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 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" This makes it a little easier to figure out what filters are active and will be used in a future patch. Signed-off-by: Stephen Finucane --- v2: - Return ordered dictionaries instead of dictionaries --- patchwork/filters.py | 13 ++++++++----- patchwork/templates/patchwork/filters.html | 2 +- patchwork/views/__init__.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/patchwork/filters.py b/patchwork/filters.py index 6cfe41c9..dd7b00db 100644 --- a/patchwork/filters.py +++ b/patchwork/filters.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: GPL-2.0-or-later +import collections + from django.contrib.auth.models import User from django.utils.html import escape from django.utils.safestring import mark_safe @@ -443,7 +445,7 @@ class Filters: self.project = project def filter_conditions(self): - kwargs = {} + kwargs = collections.OrderedDict() for f in self._filters: if f.applied: kwargs.update(f.kwargs()) @@ -456,11 +458,11 @@ class Filters: return queryset.filter(**kwargs) def params(self): - return [(f.param, f.key()) for f in self._filters - if f.key() is not None] + return collections.OrderedDict([ + (f.param, f.key()) for f in self._filters if f.key() is not None]) def querystring(self, remove=None): - params = dict(self.params()) + params = self.params() for (k, v) in self.values.items(): if k not in params: @@ -481,7 +483,8 @@ class Filters: return self.querystring(filter) def applied_filters(self): - return [x for x in self._filters if x.applied] + return collections.OrderedDict([ + (x.param, x) for x in self._filters if x.applied]) def available_filters(self): return self._filters diff --git a/patchwork/templates/patchwork/filters.html b/patchwork/templates/patchwork/filters.html index 5331ac85..e760310b 100644 --- a/patchwork/templates/patchwork/filters.html +++ b/patchwork/templates/patchwork/filters.html @@ -130,7 +130,7 @@ $(document).ready(function() {
Show patches with: {% if filters.applied_filters %} - {% for filter in filters.applied_filters %} + {% for filter in filters.applied_filters.values %} {{ filter.name }} = {{ filter.condition }} {% if not filter.forced %}