From patchwork Thu Sep 27 18:26:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 975851 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 42Ljvg0GmXz9s1c for ; Fri, 28 Sep 2018 04:27:11 +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="NI0fjOk7"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42Ljvf5kqdzF38D for ; Fri, 28 Sep 2018 04:27:10 +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="NI0fjOk7"; 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.7; helo=relay-direct7.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="NI0fjOk7"; dkim-atps=neutral Received: from relay-direct7.mxroute.com (relay-direct7.mxroute.com [185.234.75.7]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42Ljv65DKfzF37d for ; Fri, 28 Sep 2018 04:26:42 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay-direct6.mxroute.com (Postfix) with ESMTP id 49FCB3F0E2 for ; Thu, 27 Sep 2018 18:26:08 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 25D663F0F5 for ; Thu, 27 Sep 2018 18:26:08 +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=CpoDr6gG+r1ZrhqECfbdiBe8ObZPxYHrLHjSjyNPcTM=; b=NI0fjOk7xp3p9+IOwLrzMo+ec5 IB7nj6Yl0lpXXhg8vzSIotUGw3Z6hrn9itDDy4bD76hTKzAFtsd0QKZTqkJHjrcsfjHNCKjRRpOKg KVfSpyvpfWrPFoML8Sg5bVbnBRrZ6YH7PkE0QNyMPOU3DxdLuO6Xkk17J91Af24PqkJVGbAKOKtrt tUeP/VN1p5HbOG5CazbE4cwRDJcSwiBE/CVWvf8XtYexpLzNwfyGO0GCrS0ihphJ/pR8mcaRBqaZa 9qc9Mn3XfpRXaoH4VbxB9e6mPoCq64GBXz29eyBLIBxhuMDBe9ltXJsk76rMd6dvquSp2oMWsU9Ud UuG0vQOA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 1/2] filters: Return dictionaries Date: Thu, 27 Sep 2018 19:26:00 +0100 Message-Id: <20180927182601.4676-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 --- patchwork/filters.py | 7 +++---- patchwork/templates/patchwork/filters.html | 2 +- patchwork/views/__init__.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/patchwork/filters.py b/patchwork/filters.py index 6cfe41c9..75eaedd6 100644 --- a/patchwork/filters.py +++ b/patchwork/filters.py @@ -456,11 +456,10 @@ 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 {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 +480,7 @@ class Filters: return self.querystring(filter) def applied_filters(self): - return [x for x in self._filters if x.applied] + return {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 %} X-Patchwork-Id: 975850 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 42LjvF1lbnz9s3Z for ; Fri, 28 Sep 2018 04:26:49 +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="i9bYLb4q"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42LjvD6yYczF37w for ; Fri, 28 Sep 2018 04:26:48 +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="i9bYLb4q"; 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.7; helo=relay-direct7.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="i9bYLb4q"; dkim-atps=neutral Received: from relay-direct7.mxroute.com (relay-direct7.mxroute.com [185.234.75.7]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42Ljv656G4zDr4h for ; Fri, 28 Sep 2018 04:26:42 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay-direct6.mxroute.com (Postfix) with ESMTP id DD5673F347; Thu, 27 Sep 2018 18:26:08 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id C4FA03F0F5; Thu, 27 Sep 2018 18:26:08 +0000 (UTC) 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: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0uC9VwNdnLRQJv3OGw7dWvYJL8p2nP5FKTpafQzRz5A=; b=i9bYLb4q4Zs4UnfDN6bvvqP0WY 9Aoze5m2yhnyvxtLtcnVR3C5nMCtioOwEs8e57gw/OkqkA/rmNr/BSzDE+rovlF2ouF8atviBQRe6 axViQHC1CJkzGQUcHD785Bik9GyuOLF91XSTgWV0ny3IxmJ9fRX+Zn5DXOJPVQ/pyXmUqSTkak5xc mP4IDIP7bapyiu+H/ihnn/507xQwsI8ogDuz7AtvET3js2/ZFH9gOICPIQiPjiFRV0fhwbgE2/oA9 7OstSDmvi0CPN0WQKV2lLbvQRB92Y2s28sA9IBvTlJg8s3eEahYBmoTsYwa9fc2dkTH2oY+nXBsf+ h9XTKqhg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 2/2] filters: Pre-populate delegate, submitter filters Date: Thu, 27 Sep 2018 19:26:01 +0100 Message-Id: <20180927182601.4676-2-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180927182601.4676-1-stephen@that.guru> References: <20180927182601.4676-1-stephen@that.guru> 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: , Cc: Thomas Monjalon MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This appears to have got lost in the transition to 'selectize.js'. In brief, this will ensure that a previously selected delegate or submitter is still enabled post-filtering. For more information, see [1]. [1] https://stackoverflow.com/a/45124779 Signed-off-by: Stephen Finucane Cc: Thomas Monjalon Closes: #78 --- patchwork/templates/patchwork/filters.html | 40 ++++++++++++++++------ 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/patchwork/templates/patchwork/filters.html b/patchwork/templates/patchwork/filters.html index e760310b..7040287c 100644 --- a/patchwork/templates/patchwork/filters.html +++ b/patchwork/templates/patchwork/filters.html @@ -16,8 +16,6 @@ function filter_click() form.style['display'] = 'block'; filterform_displayed = true; } - - } Selectize.define('enter_key_submit', function (options) { @@ -65,13 +63,25 @@ $(document).ready(function() { return '
' + escape(item.email) + '
'; } }, +{% if "submitter" in filters.applied_filters %} +{% with submitter=filters.applied_filters.submitter.person %} + options: [ + { + pk: {{ submitter.id }}, + name: "{{ submitter.name }}", + email: "{{ submitter.email }}" + } + ], + items: [{{ submitter.id }} ], +{% endwith %} +{% endif %} load: function(query, callback) { if (query.length < 4) return callback(); req = $.ajax({ - url: '{% url 'api-submitters' %}?q=' + - encodeURIComponent(query) + '&l=10', + url: "{% url 'api-submitters' %}", + data: {q: encodeURIComponent(query), l: 10}, error: function() { callback(); }, @@ -81,10 +91,7 @@ $(document).ready(function() { }); } }); -}); - -$(document).ready(function() { $('#delegate_input').selectize({ valueField: 'pk', labelField: 'name', @@ -110,10 +117,23 @@ $(document).ready(function() { return '
' + escape(item.name) + '
'; } }, +{% if "delegate" in filters.applied_filters %} +{% with delegate=filters.applied_filters.delegate.delegate %} + options: [ + { + pk: {{ delegate.id }}, + name: "{{ delegate.profile.name }}", + email: "{{ delegate.email }}" + } + ], + items: [{{ delegate.id }} ], +{% endwith %} +{% endif %} + items: [{{ filters.params.delegate }}], load: function(query, callback) { req = $.ajax({ - url: '{% url 'api-delegates' %}?q=' + - encodeURIComponent(query) + '&l=10', + url: "{% url 'api-delegates' %}", + data: {q: encodeURIComponent(query), l: 10}, error: function() { callback(); }, @@ -167,5 +187,3 @@ $(document).ready(function() {
- -