From nobody Fri Apr 26 19:05:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535054466921152.5666760383674; Thu, 23 Aug 2018 13:01:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 629443B7F; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F9B630912F4; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 405F118005CD; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NK14Z9027498 for ; Thu, 23 Aug 2018 16:01:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C261309132E; Thu, 23 Aug 2018 20:01:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6348B30912F5 for ; Thu, 23 Aug 2018 20:01:00 +0000 (UTC) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6944E308A96F for ; Thu, 23 Aug 2018 20:00:59 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id v90-v6so5626704wrc.0 for ; Thu, 23 Aug 2018 13:00:59 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v5-v6sm4330793wru.60.2018.08.23.13.00.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 13:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=eGilr6SwLNZuwdckdZ8zuLKMY377omtcIQ62hsMJVUQ=; b=F/Xhj0GrdvS2WDt18ziRlqteiYbjppn6Qo3XvZsTqCAH9JxbCKa6HbDlKv7nQIRnXE lhOgSpfpVCpVVpJGUjOlxeq9sNVzfZDG+sPHh+Yva67piPEhlzA9oehXpV4zjFRQeRTt 5Ido3NrdOZwvG3WsvbBZyu8p7ygj02Iry2H2bHTyorlJvVC9fL6jN/4jcUlCIh4R+M1u cpEKwV+Y/90crTJKo6tEFEVwo6ZGPMBbuLHqJICKfhrwkv8TPAy1P+16I595sALBr26j Ptk4um8jdJuCsR7Z1BUmErGhlwrZ4h79mxU3o85yOCGiT+Shdg6dhHyAxiUm+VIkXOLk xm7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=eGilr6SwLNZuwdckdZ8zuLKMY377omtcIQ62hsMJVUQ=; b=jWvvksxlkPfXyZztuFf1L82etqCEoV7AGgOD4pWQ5fG8yPQvHT6ZoJhP/cZmVGH+Mf P823Cn+DcrbTynUG98GWP5tbdmlMTAtk0i5C7Z/TCpOcq0iNcgHgRESWyK2BN2/wuF42 2PY0WBQVdlS8dQJ3GXwrbroIorkVquMShEfwC+LROyPrGXevAvX0qzhj2irKIchiaB1I MulaetCm07p4Do/2lbPWBMUPUaen8Xe0ejt5g7Irv7JQYsJwcxu1gNzqM80xcnreA6g9 df6kWdXyF4oEFuBw1qpfIXhqcRifbi1+YWwjSPKiJ7DJ+hnQE+LhnF1pS1PO3THpEAa3 UmSw== X-Gm-Message-State: APzg51CR+H9PwdrNXnYkBnzG6xyNMgh+bEvVqlhYY9NrJjmjd30VJSJJ r7WY3Pc6PCpOqqBNKlALauo5DXbp X-Google-Smtp-Source: ANB0VdYff3msYfWK+RF+W0phi5kFW/3YJFdAg4VSbKUWElvUn4/x8lX+z4QXOgOSI1CtyZ5aXvJt/w== X-Received: by 2002:adf:cc91:: with SMTP id p17-v6mr4771348wrj.226.1535054457863; Thu, 23 Aug 2018 13:00:57 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 23 Aug 2018 22:00:50 +0200 Message-Id: <20180823200055.2389-2-pbonzini@redhat.com> In-Reply-To: <20180823200055.2389-1-pbonzini@redhat.com> References: <20180823200055.2389-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 23 Aug 2018 20:00:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 23 Aug 2018 20:00:59 +0000 (UTC) for IP:'209.85.221.48' DOMAIN:'mail-wr1-f48.google.com' HELO:'mail-wr1-f48.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.24 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.221.48 mail-wr1-f48.google.com 209.85.221.48 mail-wr1-f48.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 1/6] search: split _process_term into separate functions X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 23 Aug 2018 20:01:05 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is a first step towards turning it into something like a recursive descent parser. --- api/search.py | 128 +++++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/api/search.py b/api/search.py index 63ccfaa..fcf4222 100644 --- a/api/search.py +++ b/api/search.py @@ -123,19 +123,76 @@ Search text keyword in the email message. Example: regression =20 """ + def _make_filter_age(self, cond): + import datetime + def human_to_seconds(n, unit): + if unit =3D=3D "d": + return n * 86400 + elif unit =3D=3D "w": + return n * 86400 * 7 + elif unit =3D=3D "m": + return n * 86400 * 30 + elif unit =3D=3D "y": + return n * 86400 * 365 + raise Exception("No unit specified") + + if cond.startswith("<"): + less =3D True + cond =3D cond[1:] + elif cond.startswith(">"): + less =3D False + cond =3D cond[1:] + else: + less =3D False + num, unit =3D cond[:-1], cond[-1].lower() + if not num.isdigit() or not unit in "dwmy": + raise InvalidSearchTerm("Invalid age string: %s" % cond) + sec =3D human_to_seconds(int(num), unit) + p =3D datetime.datetime.now() - datetime.timedelta(0, sec) + if less: + q =3D Q(date__gte=3Dp) + else: + q =3D Q(date__lte=3Dp) + return q + + def _make_filter_keywords(self, t): + self._last_keywords.append(t) + return Q(subject__icontains=3Dt) + + def _make_filter_is(self, cond): + if cond =3D=3D "complete": + return Q(is_complete=3DTrue) + elif cond =3D=3D "pull": + return Q(subject__contains=3D'[PULL') | Q(subject__contains=3D= '[GIT PULL') + elif cond =3D=3D "reviewed": + return Q(properties__name=3D"reviewed", + properties__value=3D"true") + elif cond in ("obsoleted", "old"): + return Q(properties__name=3D"obsoleted-by", + properties__value__isnull=3DFalse) & \ + ~Q(properties__name=3D"obsoleted-by", + properties__value__iexact=3D'') + elif cond =3D=3D "applied": + return Q(properties__name=3D"git.tag", + properties__value__isnull=3DFalse) & \ + ~Q(properties__name=3D"git.tag", + properties__value__iexact=3D'') + elif cond =3D=3D "tested": + return Q(properties__name=3D"testing.done", + properties__value=3D"true") + elif cond =3D=3D "merged": + return Q(is_merged=3DTrue) + return self._make_filter_keywords(self, term) + def _process_term(self, query, term, neg=3DFalse): """ Return a Q object that will be applied to the query """ - def as_keywords(t): - self._last_keywords.append(t) - return Q(subject__icontains=3Dt) - if term.startswith("!"): return self._process_term(query, term[1:], not neg) if term.startswith("age:"): cond =3D term[term.find(":") + 1:] - q =3D self._process_age_term(query, cond) + q =3D self._make_filter_age(cond) elif term[0] in "<>" and len(term) > 1: - q =3D self._process_age_term(query, term) + q =3D self._make_filter_age(term) elif term.startswith("from:"): cond =3D term[term.find(":") + 1:] q =3D Q(sender__icontains=3Dcond) @@ -157,30 +214,7 @@ Search text keyword in the email message. Example: else: cond =3D term[term.find(":") + 1:] lneg =3D term.startswith("not:") - if cond =3D=3D "complete": - q =3D Q(is_complete=3DTrue) - elif cond =3D=3D "pull": - q =3D Q(subject__contains=3D'[PULL') | Q(subject__contains= =3D'[GIT PULL') - elif cond =3D=3D "reviewed": - q =3D Q(properties__name=3D"reviewed", - properties__value=3D"true") - elif cond in ("obsoleted", "old"): - q =3D Q(properties__name=3D"obsoleted-by", - properties__value__isnull=3DFalse) & \ - ~Q(properties__name=3D"obsoleted-by", - properties__value__iexact=3D'') - elif cond =3D=3D "applied": - q =3D Q(properties__name=3D"git.tag", - properties__value__isnull=3DFalse) & \ - ~Q(properties__name=3D"git.tag", - properties__value__iexact=3D'') - elif cond =3D=3D "tested": - q =3D Q(properties__name=3D"testing.done", - properties__value=3D"true") - elif cond =3D=3D "merged": - q =3D Q(is_merged=3DTrue) - else: - q =3D as_keywords(term) + q =3D self._make_filter_is(cond) if lneg: neg =3D not neg elif term.startswith("has:"): @@ -195,7 +229,7 @@ Search text keyword in the email message. Example: q =3D Q(project__name=3Dcond) | Q(project__parent_project__nam= e=3Dcond) else: # Keyword in subject is the default - q =3D as_keywords(term) + q =3D self._make_filter_keywords(term) if neg: return query.exclude(pk__in=3Dquery.filter(q)) else: @@ -215,35 +249,3 @@ Search text keyword in the email message. Example: for t in terms: queryset =3D self._process_term(queryset, t) return queryset - - def _process_age_term(self, query, cond): - import datetime - def human_to_seconds(n, unit): - if unit =3D=3D "d": - return n * 86400 - elif unit =3D=3D "w": - return n * 86400 * 7 - elif unit =3D=3D "m": - return n * 86400 * 30 - elif unit =3D=3D "y": - return n * 86400 * 365 - raise Exception("No unit specified") - - if cond.startswith("<"): - less =3D True - cond =3D cond[1:] - elif cond.startswith(">"): - less =3D False - cond =3D cond[1:] - else: - less =3D False - num, unit =3D cond[:-1], cond[-1].lower() - if not num.isdigit() or not unit in "dwmy": - raise InvalidSearchTerm("Invalid age string: %s" % cond) - sec =3D human_to_seconds(int(num), unit) - p =3D datetime.datetime.now() - datetime.timedelta(0, sec) - if less: - q =3D Q(date__gte=3Dp) - else: - q =3D Q(date__lte=3Dp) - return q --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 19:05:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535054466922270.26494590724224; Thu, 23 Aug 2018 13:01:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B95164E4E6; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A94DC30912F4; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 99B6F4BB75; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NK149C027497 for ; Thu, 23 Aug 2018 16:01:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 65DA5308BDA0; Thu, 23 Aug 2018 20:01:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BBD0308BE72 for ; Thu, 23 Aug 2018 20:01:02 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 76A62C01BD33 for ; Thu, 23 Aug 2018 20:01:00 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id j192-v6so6745681wmj.1 for ; Thu, 23 Aug 2018 13:01:00 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v5-v6sm4330793wru.60.2018.08.23.13.00.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 13:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=9yVD21tAZESbLOWzuXnTkHXgxeUSbczrM81VsvmroxI=; b=uiXlkIADXASEVUYNrjeQoDNgVqbbL/CYTD9RvQmYS00iqwvoCR0tV0EAX+fxQip8Ac c/2ene20s6JP0FMXY4Fyn7LkVrpuWQqeQJeW4sSS1RFgtCYSbRE7fB7XMPSUsc0I7g+N 2hh9UoAksPPamZW9IZ12j+L8t3IG+9d7333f7xpIQfEZjBjPJ2GxdknnR40taTvGnoUm GlnilrZHtbsp1dJhdW/9U94q7e2UmcP3rFkOHyT7ob6kyo47dP5s2KZz3xw/cZUdvCvV GNb1Py5PS08Nfs0HR/PQ0iwwffLsFkez4eOZgCikPqvtFI5nhzsGj/7VWHMY3mxYkMQp el1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=9yVD21tAZESbLOWzuXnTkHXgxeUSbczrM81VsvmroxI=; b=OY3CX03FBqN53AQvbPHaj+/hL7cF6LKzViwpOyIObT/riDaTgLnHr3G/0EjdQDLcKw CpSKLrMV4ErgUg/l5JKoi5Qwp31P9ZtPmPZpVeWpnUZjK/VfS/tACOgizSlGBloL3Kkj I5GLqGNOPcybNq4Crw5Y6AhjlbkssGINlamw987PGGg8kgePGnQJ4nwDLmpqpXHCMILA gNGoe0BHra1tkBSvrFrPOpZE7zzsZNMEh+FIeNktjnPkx5h65slvg1jnW5EgVcddBnXR tuGwUQOHg9PB2MCoMqCaiFVvncJJr8kcojQT2e98/A0f4AvjjPofDMbBqitciqhZyfhg 0YqA== X-Gm-Message-State: APzg51DrJwRokJJy+IadIr7s4r+eQnwVaAhskUsureweetfaQ6m+Rj5+ AZBKrqkMBOKq16vquvr88vvNvUlj X-Google-Smtp-Source: ANB0VdaYy3sUebLWWRK8B+aW8e+emX5ypQWuAZwnv8q98LeSY0UZrIX9EznD4MrSaHI2dOjCOEhKXA== X-Received: by 2002:a1c:5e08:: with SMTP id s8-v6mr6556308wmb.88.1535054458813; Thu, 23 Aug 2018 13:00:58 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 23 Aug 2018 22:00:51 +0200 Message-Id: <20180823200055.2389-3-pbonzini@redhat.com> In-Reply-To: <20180823200055.2389-1-pbonzini@redhat.com> References: <20180823200055.2389-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 Aug 2018 20:01:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 Aug 2018 20:01:00 +0000 (UTC) for IP:'74.125.82.67' DOMAIN:'mail-wm0-f67.google.com' HELO:'mail-wm0-f67.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.221 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 74.125.82.67 mail-wm0-f67.google.com 74.125.82.67 mail-wm0-f67.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 2/6] search: push handling of +/- to top parsing function, simplify ! X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 23 Aug 2018 20:01:05 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Define "+" as "imply an is: if there is no colon" and "-" as "imply a not: if there is no colon". It is possible however to write "-has:replies" for example. For simplicity, only allow one of +/-/!. It is not possible anymore to write "!!x" to mean "x". Signed-off-by: Paolo Bonzini --- api/search.py | 56 +++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/api/search.py b/api/search.py index fcf4222..fd30ee5 100644 --- a/api/search.py +++ b/api/search.py @@ -182,54 +182,58 @@ Search text keyword in the email message. Example: properties__value=3D"true") elif cond =3D=3D "merged": return Q(is_merged=3DTrue) - return self._make_filter_keywords(self, term) + return None =20 - def _process_term(self, query, term, neg=3DFalse): - """ Return a Q object that will be applied to the query """ - if term.startswith("!"): - return self._process_term(query, term[1:], not neg) + def _make_filter(self, term): if term.startswith("age:"): cond =3D term[term.find(":") + 1:] - q =3D self._make_filter_age(cond) + return self._make_filter_age(cond) elif term[0] in "<>" and len(term) > 1: - q =3D self._make_filter_age(term) + return self._make_filter_age(term) elif term.startswith("from:"): cond =3D term[term.find(":") + 1:] - q =3D Q(sender__icontains=3Dcond) + return Q(sender__icontains=3Dcond) elif term.startswith("to:"): cond =3D term[term.find(":") + 1:] - q =3D Q(recipients__icontains=3Dcond) + return Q(recipients__icontains=3Dcond) elif term.startswith("subject:"): cond =3D term[term.find(":") + 1:] - q =3D Q(subject__icontains=3Dcond) + return Q(subject__icontains=3Dcond) elif term.startswith("id:"): cond =3D term[term.find(":") + 1:] if cond[0] =3D=3D "<" and cond[-1] =3D=3D ">": cond =3D cond[1:-1] - q =3D Q(message_id=3Dcond) - elif term.startswith("is:") or term.startswith("not:") or term[0] = in "+-": - if term[0] in "+-": - cond =3D term[1:] - lneg =3D term[0] =3D=3D "-" - else: - cond =3D term[term.find(":") + 1:] - lneg =3D term.startswith("not:") - q =3D self._make_filter_is(cond) - if lneg: - neg =3D not neg + return Q(message_id=3Dcond) + elif term.startswith("is:"): + return self._make_filter_is(term[3:]) or self._make_filter_key= words(term) + elif term.startswith("not:"): + return ~self._make_filter_is(term[4:]) or self._make_filter_ke= ywords(term) elif term.startswith("has:"): cond =3D term[term.find(":") + 1:] if cond =3D=3D "replies": - q =3D Q(last_comment_date__isnull=3DFalse) + return Q(last_comment_date__isnull=3DFalse) else: - q =3D Q(properties__name=3Dcond) + return Q(properties__name=3Dcond) elif term.startswith("project:"): cond =3D term[term.find(":") + 1:] self._projects.add(cond) - q =3D Q(project__name=3Dcond) | Q(project__parent_project__nam= e=3Dcond) + return Q(project__name=3Dcond) | Q(project__parent_project__na= me=3Dcond) + + # Keyword in subject is the default + return self._make_filter_keywords(term) + + def _process_term(self, query, term, neg=3DFalse): + """ Return a Q object that will be applied to the query """ + is_plusminus =3D False + if term[0] in "+-!": + term =3D term[1:] + neg =3D neg ^ (term[0] !=3D "+") + is_plusminus =3D (term[0] !=3D "!") + + if is_plusminus and ":" not in term: + q =3D self._make_filter_is(term) or self._make_filter_keywords= (term) else: - # Keyword in subject is the default - q =3D self._make_filter_keywords(term) + q =3D self._make_filter(term) if neg: return query.exclude(pk__in=3Dquery.filter(q)) else: --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 19:05:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535054467411191.0828829170182; Thu, 23 Aug 2018 13:01:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2CFC30001E0; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C0CDB7F65D; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AEF3F4A464; Thu, 23 Aug 2018 20:01:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NK14AH027512 for ; Thu, 23 Aug 2018 16:01:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF5442010D5D; Thu, 23 Aug 2018 20:01:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D51BE2010D16 for ; Thu, 23 Aug 2018 20:01:02 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B3453086271 for ; Thu, 23 Aug 2018 20:01:01 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id k5-v6so5602213wre.10 for ; Thu, 23 Aug 2018 13:01:01 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v5-v6sm4330793wru.60.2018.08.23.13.00.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 13:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=D6BTIjS7smfHtn7PMwdxcsUdj+6DrUUZne/tzCeH6Cw=; b=W8O0FasxjDXsaalvCXaHI8lkGBPRvZXQ6FD1Aruhka9w33hC6eEmgck8DOG6Ecf7tR ybnBOroexVtSZPxMURsY7DnZV255n2FceVaAaRCAqt3PmHJcZU67IwZGHyIJpjEcgMvD /0IcgYWkmwVsWEgVsxtjW8VJaDYKUJ4RaECKeG5FOPlk1fE8bVZiAS1N9dKtP97y6fRZ R3hWHTYF8LsOg6peYn1gk7Qb0n1r+0wER8VkNFdaND5OPZxuaB1TzH01HBor9tSPYele YQoCCxQ24YGczKOSqt6C+5mdTD3x93OGQO809/hz7qaxnxa7op091xmVKxQmMnsP7qDK KjHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=D6BTIjS7smfHtn7PMwdxcsUdj+6DrUUZne/tzCeH6Cw=; b=LhK06Rgr/gdKTHOCqRK/i1m6LXho0FV81yr7IPva3O/soNynenIoCyhbKfxsaCHNNk MszJZ9rnNR1KXYG4P3ugkg4rIEm5vANbl7m4D5AC1pwFMRWlPE/QME9VxWI8zYkeQ3qN 9FXC98ND/olLo95qdQ7O1UIIqIidGXJtv8xtxpH1jtFaHLk8kmoKaKc9JlNPal/7Kf7r ZquO0hZi5HdrWzp8O30iY+ETzb/Z6tJV7qOHqsBcUeQdyGCD/yMCEGXYgB0H//EueGJK HANjDolmbLTxjn58ubsn1wUTR7neGcmZ0NG7ow8UfoB/rv+EWWcjNViMolLHWgFWTv26 +naA== X-Gm-Message-State: APzg51ByfZL5ROY0vpjCiRbnw8adOZqitVc4QWzRHvmhh0ATY70RZE8v JsXXu6S8e/eJgUFTdwTV0LtiDnas X-Google-Smtp-Source: ANB0VdbJwLxZNgueQLAUXYYYWEk4gTbjgmluSMkr3SAyphNkZCyTDUem98YLZpzeyv0Y3QhSJLJaiQ== X-Received: by 2002:a5d:53cf:: with SMTP id a15-v6mr13654595wrw.151.1535054459617; Thu, 23 Aug 2018 13:00:59 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 23 Aug 2018 22:00:52 +0200 Message-Id: <20180823200055.2389-4-pbonzini@redhat.com> In-Reply-To: <20180823200055.2389-1-pbonzini@redhat.com> References: <20180823200055.2389-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 23 Aug 2018 20:01:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 23 Aug 2018 20:01:01 +0000 (UTC) for IP:'209.85.221.65' DOMAIN:'mail-wr1-f65.google.com' HELO:'mail-wr1-f65.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.24 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.221.65 mail-wr1-f65.google.com 209.85.221.65 mail-wr1-f65.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 3/6] search: add search by result X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 23 Aug 2018 20:01:05 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- api/search.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/api/search.py b/api/search.py index fd30ee5..7e11da4 100644 --- a/api/search.py +++ b/api/search.py @@ -8,7 +8,7 @@ # This work is licensed under the MIT License. Please see the LICENSE fil= e or # http://opensource.org/licenses/MIT. =20 -from .models import Message +from .models import Message, Result from django.db.models import Q =20 class InvalidSearchTerm(Exception): @@ -89,6 +89,21 @@ Compare the address info of message. Example: =20 --- =20 +### Search by result + +Syntax: + + - pending:NAME, success:NAME, failure:NAME, running:NAME + +where NAME can be e.g. "git", "testing", "testing.TEST-NAME" + +Example: + + success:git + failure:testing.FreeBSD + +--- + ### Reverse condition =20 - Syntax: !TERM @@ -184,6 +199,9 @@ Search text keyword in the email message. Example: return Q(is_merged=3DTrue) return None =20 + def _make_filter_result(self, term, **kwargs): + return Q(results__name=3Dterm, **kwargs) | Q(results__name__starts= with=3Dterm+'.', **kwargs) + def _make_filter(self, term): if term.startswith("age:"): cond =3D term[term.find(":") + 1:] @@ -214,6 +232,14 @@ Search text keyword in the email message. Example: return Q(last_comment_date__isnull=3DFalse) else: return Q(properties__name=3Dcond) + elif term.startswith("failure:"): + return self._make_filter_result(term[8:], results__status=3DRe= sult.FAILURE) + elif term.startswith("success:"): + return self._make_filter_result(term[8:], results__status=3DRe= sult.SUCCESS) + elif term.startswith("pending:"): + return self._make_filter_result(term[8:], results__status=3DRe= sult.PENDING) + elif term.startswith("running:"): + return self._make_filter_result(term[8:], results__status=3DRe= sult.RUNNING) elif term.startswith("project:"): cond =3D term[term.find(":") + 1:] self._projects.add(cond) --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 19:05:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535054469272195.6965473716523; Thu, 23 Aug 2018 13:01:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EEFCE7F3F5; Thu, 23 Aug 2018 20:01:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFEC479A2B; Thu, 23 Aug 2018 20:01:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C85F618005CD; Thu, 23 Aug 2018 20:01:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NK16lw027525 for ; Thu, 23 Aug 2018 16:01:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C12034193; Thu, 23 Aug 2018 20:01:06 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2283A34192 for ; Thu, 23 Aug 2018 20:01:03 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A1C4811B7 for ; Thu, 23 Aug 2018 20:01:02 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id j26-v6so5625111wre.2 for ; Thu, 23 Aug 2018 13:01:02 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v5-v6sm4330793wru.60.2018.08.23.13.00.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 13:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=XoE+Cis5G1lNhHNenheU9/iJjSLDtUZHaV4CmhdwXvA=; b=bmnRprHtAzzTKE7maPO8Gtvum1HdihQEz4bjxSJHZv4hgZI/87iWrkfT9x7GCyCnFN nYayDlwqeGYjtNuPWFVvUfdYbJBNfv2abOiFpVhps2pxTV8M12b/wafRWyeE1VLxzooQ FQxm1yg67ZBBfRbYnYeiLWs4Ah2d62f4pM+ljcnTCVti5TxXgVf//l0jq4RJQg5Lmfjc mNSDjTuFdcMD+t5LPFH1RDCajgPkfkbtYox+ot2bXeIUi5GGbeUXCYW4TNbfSL9H30Vw pPeV8dRC/oZbyxV6nrlaer/jQ0/AWCKZP/uIPOWdA0B/LUF1EgfSLjxsTO4Ltw92PClq VqfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=XoE+Cis5G1lNhHNenheU9/iJjSLDtUZHaV4CmhdwXvA=; b=LseaXP5o9iu8L/GKAMh+cpeudpUeisgY+N7Q88voA0SC2bdV4Fz+fS/YVUhEqvZyoF SzoqSeV0S4cPfWbYieVFwnTRHQXChcWmx4WOQGs3nUyOfjOVgphmuVkBr1IlvU9Ax9SB vetqZe57texS5zX0pUHhAOhEsCQhVEMIQp7wgySHmY0K+Q1Z9/mZXG5vGkxurN0gNoz7 i9XxRjysU58hy+vcMKjzcQkZttTBIDtDllM08eyQK9SP6fhYx7DBS6an0qkmkaH5Gdss O1wQZC1Nwtx1Aj/6Qi2KXME8eIIZz3O5rIO+9J1fYARhU6QMqbL5bClYw0YW9AC0bmTf cKfw== X-Gm-Message-State: AOUpUlEnkCHCF9WQewy1iawbVdxRnXMZG2O/wAvSRJ2B9sAvk0eupDD4 yyEKqQpP5cTkLsPJ3ISdZTAFaWrH X-Google-Smtp-Source: AA+uWPxGhRi4ZJnSn2DHkR0eJ7VA9a/h+BBJY+vzVogWQqTO6IaH734fqcegxPBHQc6tH+rW5U/hAA== X-Received: by 2002:adf:a41c:: with SMTP id d28-v6mr19682908wra.121.1535054460632; Thu, 23 Aug 2018 13:01:00 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 23 Aug 2018 22:00:53 +0200 Message-Id: <20180823200055.2389-5-pbonzini@redhat.com> In-Reply-To: <20180823200055.2389-1-pbonzini@redhat.com> References: <20180823200055.2389-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 23 Aug 2018 20:01:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 23 Aug 2018 20:01:02 +0000 (UTC) for IP:'209.85.221.65' DOMAIN:'mail-wr1-f65.google.com' HELO:'mail-wr1-f65.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.24 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.221.65 mail-wr1-f65.google.com 209.85.221.65 mail-wr1-f65.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 4/6] search: pass user to search X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Aug 2018 20:01:08 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This will be used to support reviews. Signed-off-by: Paolo Bonzini --- api/rest.py | 2 +- api/search.py | 10 +++++----- api/views.py | 4 ++-- mods/testing.py | 2 +- www/views.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api/rest.py b/api/rest.py index 9c2497b..6c10edb 100644 --- a/api/rest.py +++ b/api/rest.py @@ -322,7 +322,7 @@ class PatchewSearchFilter(filters.BaseFilterBackend): search =3D request.query_params.get(self.search_param) or '' terms =3D [x.strip() for x in search.split(" ") if x] se =3D SearchEngine() - query =3D se.search_series(queryset=3Dqueryset, *terms) + query =3D se.search_series(queryset=3Dqueryset, user=3Drequest.use= r, *terms) return query =20 def to_html(self, request, queryset, view): diff --git a/api/search.py b/api/search.py index 7e11da4..aa77f22 100644 --- a/api/search.py +++ b/api/search.py @@ -202,7 +202,7 @@ Search text keyword in the email message. Example: def _make_filter_result(self, term, **kwargs): return Q(results__name=3Dterm, **kwargs) | Q(results__name__starts= with=3Dterm+'.', **kwargs) =20 - def _make_filter(self, term): + def _make_filter(self, term, user): if term.startswith("age:"): cond =3D term[term.find(":") + 1:] return self._make_filter_age(cond) @@ -248,7 +248,7 @@ Search text keyword in the email message. Example: # Keyword in subject is the default return self._make_filter_keywords(term) =20 - def _process_term(self, query, term, neg=3DFalse): + def _process_term(self, query, term, user, neg=3DFalse): """ Return a Q object that will be applied to the query """ is_plusminus =3D False if term[0] in "+-!": @@ -259,7 +259,7 @@ Search text keyword in the email message. Example: if is_plusminus and ":" not in term: q =3D self._make_filter_is(term) or self._make_filter_keywords= (term) else: - q =3D self._make_filter(term) + q =3D self._make_filter(term, user) if neg: return query.exclude(pk__in=3Dquery.filter(q)) else: @@ -271,11 +271,11 @@ Search text keyword in the email message. Example: def project(self): return next(iter(self._projects)) if len(self._projects) =3D=3D 1 = else None =20 - def search_series(self, *terms, queryset=3DNone): + def search_series(self, *terms, user=3DNone, queryset=3DNone): self._last_keywords =3D [] self._projects =3D set() if queryset is None: queryset =3D Message.objects.series_heads() for t in terms: - queryset =3D self._process_term(queryset, t) + queryset =3D self._process_term(queryset, t, user) return queryset diff --git a/api/views.py b/api/views.py index f2262b6..32bceab 100644 --- a/api/views.py +++ b/api/views.py @@ -185,7 +185,7 @@ class SearchView(APIView): =20 def handle(self, request, terms, fields=3DNone): se =3D SearchEngine() - r =3D se.search_series(*terms) + r =3D se.search_series(user=3Drequest.user, *terms) return [prepare_series(request, x, fields) for x in r] =20 class ImportView(APILoginRequiredView): @@ -211,7 +211,7 @@ class DeleteView(APILoginRequiredView): Message.objects.all().delete() else: se =3D SearchEngine() - for r in se.search_series(*terms): + for r in se.search_series(user=3Drequest.user, *terms): Message.objects.delete_subthread(r) =20 class Logout(APIView): diff --git a/mods/testing.py b/mods/testing.py index ecd63d1..16b5c59 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -508,6 +508,6 @@ class UntestView(APILoginRequiredView): =20 def handle(self, request, terms): se =3D SearchEngine() - q =3D se.search_series(*terms) + q =3D se.search_series(user=3Drequest.user, *terms) for s in q: _instance.clear_and_start_testing(s) diff --git a/www/views.py b/www/views.py index d7c60dd..1259a8e 100644 --- a/www/views.py +++ b/www/views.py @@ -224,7 +224,7 @@ def view_search(request): search =3D request.GET.get("q", "").strip() terms =3D [x.strip() for x in search.split(" ") if x] se =3D SearchEngine() - query =3D se.search_series(*terms) + query =3D se.search_series(user=3Drequest.user, *terms) return render_series_list_page(request, query, search=3Dsearch, project=3Dse.project(), keywords=3Dse.last_keywords()) --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 19:05:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535054468803494.9903229321711; Thu, 23 Aug 2018 13:01:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B7C63082A41; Thu, 23 Aug 2018 20:01:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7559C1062241; Thu, 23 Aug 2018 20:01:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5DEC118005CD; Thu, 23 Aug 2018 20:01:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NK1637027537 for ; Thu, 23 Aug 2018 16:01:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 99E077DFE8; Thu, 23 Aug 2018 20:01:06 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 91C067DFE7 for ; Thu, 23 Aug 2018 20:01:04 +0000 (UTC) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04F7E308338E for ; Thu, 23 Aug 2018 20:01:03 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id m27-v6so5611385wrf.3 for ; Thu, 23 Aug 2018 13:01:02 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v5-v6sm4330793wru.60.2018.08.23.13.01.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 13:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=q5eWrI2kWogtaVi3eEO9Xr1x553Cf4kdmeg90vAybrg=; b=GtEDY2o8/riHe2WvmLmFpLJFvSvSsHnMa6OIw2uKum/qmvr8SG57Ly6jxaibgAVvhH jn9QYiK4tqYEeASTPM6YetwLbUnNhipQWU/5aJ7XUqlbsgz7ojgVS3aw3/lLKYhEpVgA 1AY5nhzb4YcwZltyGwkzHwpORJm+15TPLu30abItHwDXOMXtV2zgBGlNEY+cbiLddqAV sxBeHsIeq24WPvS0L8FNQsq5swII13Ky+NDepk97O/jp1WdFCbScH/y9t25MVE7Wnchq mrg3WB53GIx+U0ZkFT8XBdFs5ecRqiQH6o9nRlwWFAO5FXv69BpbUNDfFY7gHwD5/XKW J5BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=q5eWrI2kWogtaVi3eEO9Xr1x553Cf4kdmeg90vAybrg=; b=ROb0eGPY5ec9z133jzv92UERw/RYPfAmkvl95O4DJpgbgwd0Ou840D82G7j//uj9Bg bSPqO96SKiEFfJ3eEErbmxJDEHz14gl18lYhpKm+K0TwTLMffbskYyR2o290zweqfQlo wTCHVbE0B4d25wsyI9Pd0cCbCheRwbUzwQ32Donufws6dGksrzGciUkn8esRH3u79zas KnGf6LHtQ7wLoOR1UtiXTpSZiAwpg9W4aXNnOcroiQIu1yfEglwiCIzq0oLAwFsLI5ZM OMPKci2M7ni0F+fdCjyUXpakrKRUo0FxdZc8YtyUZhZ6myjBhp8LyEnO/vyvlHaGZzXX NtFw== X-Gm-Message-State: APzg51CguI8P/vXnUs2Rg6ZBC8qpCsTdrRD+C+aIsfxyTswh4kgQof6T Fm3f+5x9u3MnHWs9ZgwGAettf/rk X-Google-Smtp-Source: ANB0VdYN5MxqByjummvO66xLQPwNRMZ2UMBwbwnx+kEm+8qW54ahAUnyJAK91yAqYbSxpIS+q3+z1w== X-Received: by 2002:adf:f984:: with SMTP id f4-v6mr13000126wrr.105.1535054461478; Thu, 23 Aug 2018 13:01:01 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 23 Aug 2018 22:00:54 +0200 Message-Id: <20180823200055.2389-6-pbonzini@redhat.com> In-Reply-To: <20180823200055.2389-1-pbonzini@redhat.com> References: <20180823200055.2389-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 23 Aug 2018 20:01:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 23 Aug 2018 20:01:03 +0000 (UTC) for IP:'209.85.221.49' DOMAIN:'mail-wr1-f49.google.com' HELO:'mail-wr1-f49.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.241 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.221.49 mail-wr1-f49.google.com 209.85.221.49 mail-wr1-f49.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 5/6] www: add back extra_status to series detail X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 23 Aug 2018 20:01:07 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This will be used by the review links, which are not linked to a Result. Signed-off-by: Paolo Bonzini --- static/css/base.css | 4 ++-- www/templates/series-detail.html | 10 ++++++++-- www/views.py | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/static/css/base.css b/static/css/base.css index 545aad1..7fe45e4 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -137,10 +137,10 @@ h1, h2, h3, .h1, .h2, .h3 { .status-content > .fa { color: #337ab7; } -.status-content.status-failure > .fa { +.status-content > .fa-warning { color: #CC0000; } -.status-content.status-success > .fa { +.status-content > .fa-check { color: #009900; } .status-content > div { diff --git a/www/templates/series-detail.html b/www/templates/series-detail= .html index 52b8f96..cb5d611 100644 --- a/www/templates/series-detail.html +++ b/www/templates/series-detail.html @@ -51,13 +51,13 @@ =20
{% if series.num_patches < series.total_patches %} -
+
Only {{ series.num_patches }} patches received!
{% endif %} {% for result in results %} -
+
{% if result.status =3D=3D "pending" %} {% elif result.status =3D=3D "running" %} {% elif result.status =3D=3D "failure" %} @@ -65,6 +65,12 @@
{{ result.html }}
{% endfor %} +{% for status in series.extra_status %} +
+ {% if status.icon %}{% = endif %} +
{{ status.html }}
+
+{% endfor %} =20 {% if is_head %} {% if series.get_diff_stat %} diff --git a/www/views.py b/www/views.py index 1259a8e..dd910b1 100644 --- a/www/views.py +++ b/www/views.py @@ -52,6 +52,7 @@ def prepare_message(request, project, m, detailed): }) # hook points for plugins m.has_other_revisions =3D False + m.extra_status =3D [] m.extra_ops =3D [] m.extra_links =3D [] dispatch_module_hook("prepare_message_hook", request=3Drequest, messag= e=3Dm, --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 19:05:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535054470446125.79169818842524; Thu, 23 Aug 2018 13:01:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1480B30820D5; Thu, 23 Aug 2018 20:01:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0327E2010D11; Thu, 23 Aug 2018 20:01:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E79FB4BB74; Thu, 23 Aug 2018 20:01:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NK17qI027554 for ; Thu, 23 Aug 2018 16:01:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB9A8308BDA8; Thu, 23 Aug 2018 20:01:07 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE8AE308BDA0 for ; Thu, 23 Aug 2018 20:01:06 +0000 (UTC) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CEE43082E05 for ; Thu, 23 Aug 2018 20:01:04 +0000 (UTC) Received: by mail-wr1-f46.google.com with SMTP id 20-v6so5597415wrb.12 for ; Thu, 23 Aug 2018 13:01:04 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v5-v6sm4330793wru.60.2018.08.23.13.01.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 13:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=D/6kv1+QztxfG88vwAcfV14i0uvywZSFaW+zJF14Ahs=; b=jRY3XlL8+G2SJUxVKzTovQke88RL67OufTn31QxeYjjAUwyt1H+Frau7PzsfcL2EfI lAwpOcp/F636U8OULCeG/oPb66MjsN9fA36ZuXWrCTfb8Ga8DuO1v6yT28CoPN7IR/GM viM5zMAel9AXhb3W+wzjnA1akkViYLMCCM8Tjtaxfoah2Lx+Ev0STnzwnZ9vE/ne2ikS ZySyays65CrtHzsyzFScfB7mBmSn+OencRRnczP2BTl7mtQb4iMPomlEKPvEN4Q3KwxU RYWqU+3O6iHejhVm9yOIC74Mirqlp9uHFDASSsTik3ofB40KuJLcTRtFrKNHmnP/BvnW oplQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=D/6kv1+QztxfG88vwAcfV14i0uvywZSFaW+zJF14Ahs=; b=Rxvbob2bCgwBtRw82lG7J7D2Ou2Wg2WIYddtTyMws0SsopfquxwIiqLZTjfJqGQwOr GHcPjod/7G9HtGHMMNzHf/pCj6SoRyNDNPUkCBYNE3AkiEU2F2VjG1rGNMpPZF6ijx90 xTZltZoyL9ye/dcRVaalpobrPuo84DA3DEH93hYDFfQZBmvbWriK7tTMOwGiK6UchLBs JRCuv4VJhlE5yyjgxyw2mDnF6Oh/h6P8GNFsdPy7OpqW6GjCbrVxUW9CQlPwjQfRFvq0 ECMMy2YDWxwVotnYlGgfilBYB+pofFDfC6G5lu+ANA75X/CCl0ddyQS3AVpDXlH9vB6n WvUw== X-Gm-Message-State: AOUpUlHdjCzi1ym+oaKXQKUrPAmSpcrssg6JPn5smT6QlApCLox5ZS3t Catif0QUERmfaw7UrewclRUVOkcE X-Google-Smtp-Source: AA+uWPzGTch6kYXVfUQkZ0SKQbGm4SRW42BrCLDEmkvYGGaw1SUCto6tmsyLXmii29GRmaZ+LasY0g== X-Received: by 2002:adf:d08c:: with SMTP id y12-v6mr39437521wrh.152.1535054462754; Thu, 23 Aug 2018 13:01:02 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 23 Aug 2018 22:00:55 +0200 Message-Id: <20180823200055.2389-7-pbonzini@redhat.com> In-Reply-To: <20180823200055.2389-1-pbonzini@redhat.com> References: <20180823200055.2389-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 23 Aug 2018 20:01:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 23 Aug 2018 20:01:04 +0000 (UTC) for IP:'209.85.221.46' DOMAIN:'mail-wr1-f46.google.com' HELO:'mail-wr1-f46.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.241 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.221.46 mail-wr1-f46.google.com 209.85.221.46 mail-wr1-f46.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 6/6] add Review model X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 23 Aug 2018 20:01:09 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This model has a simple many-to-many relation with series, that lets logged-in users mark series as accepted or rejected, and use the status in a query. Three new search operators are added: ack (with synonyms accept and accepted), nack (with synonyms reject and rejected), review (with synonyms reviewed). Sample useful queries include the following: - "-is:merged ack:me" (what should I merge) - "to:pbonzini@redhat.com -is:merged -reviewed:me" (what should I review) - "nvme -is:merged -reviewed:fam" (what did Fam overlook :)) Signed-off-by: Paolo Bonzini --- api/migrations/0034_auto_20180822_1106.py | 32 ++++++++++ api/models.py | 7 +++ api/search.py | 28 +++++++++ mods/maintainer.py | 72 +++++++++++++++++++++-- static/css/base.css | 2 +- 5 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 api/migrations/0034_auto_20180822_1106.py diff --git a/api/migrations/0034_auto_20180822_1106.py b/api/migrations/003= 4_auto_20180822_1106.py new file mode 100644 index 0000000..d830d47 --- /dev/null +++ b/api/migrations/0034_auto_20180822_1106.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.13 on 2018-08-22 11:06 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies =3D [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('api', '0033_auto_20180803_0809'), + ] + + operations =3D [ + migrations.CreateModel( + name=3D'Review', + fields=3D[ + ('id', models.AutoField(auto_created=3DTrue, primary_key= =3DTrue, serialize=3DFalse, verbose_name=3D'ID')), + ('accept', models.BooleanField()), + ('message', models.ForeignKey(on_delete=3Ddjango.db.models= .deletion.CASCADE, to=3D'api.Message')), + ('user', models.ForeignKey(on_delete=3Ddjango.db.models.de= letion.CASCADE, to=3Dsettings.AUTH_USER_MODEL)), + ], + ), + migrations.AddField( + model_name=3D'message', + name=3D'reviews', + field=3Dmodels.ManyToManyField(blank=3DTrue, through=3D'api.Re= view', to=3Dsettings.AUTH_USER_MODEL), + ), + ] diff --git a/api/models.py b/api/models.py index eea924f..545013e 100644 --- a/api/models.py +++ b/api/models.py @@ -419,6 +419,11 @@ class MessageManager(models.Manager): def HeaderFieldModel(**args): return models.CharField(max_length=3D4096, **args) =20 +class Review(models.Model): + user =3D models.ForeignKey(User) + message =3D models.ForeignKey('Message') + accept =3D models.BooleanField() + class Message(models.Model): """ Patch email message """ =20 @@ -455,6 +460,8 @@ class Message(models.Model): # number of patches we've got if is_series_head num_patches =3D models.IntegerField(null=3DFalse, default=3D-1, blank= =3DTrue) =20 + reviews =3D models.ManyToManyField(User, blank=3DTrue, through=3DRevie= w) + objects =3D MessageManager() =20 def save_mbox(self, mbox_blob): diff --git a/api/search.py b/api/search.py index aa77f22..bcac3ac 100644 --- a/api/search.py +++ b/api/search.py @@ -104,6 +104,18 @@ Example: =20 --- =20 +### Search by review state + +Syntax: + + - accept:USERNAME or ack:USERNAME - the series was marked as accepted by = the user + - reject:USERNAME or nack:USERNAME - the series was marked as rejected by= the user + - review:USERNAME - the series was marked as accepted or rejected by the = user + +USERNAME can be "me" to identify the current user + +--- + ### Reverse condition =20 - Syntax: !TERM @@ -202,6 +214,12 @@ Search text keyword in the email message. Example: def _make_filter_result(self, term, **kwargs): return Q(results__name=3Dterm, **kwargs) | Q(results__name__starts= with=3Dterm+'.', **kwargs) =20 + def _make_filter_review(self, username, user, **kwargs): + if username =3D=3D "me": + return Q(review__user=3Duser, **kwargs) + else: + return Q(review__user__username=3Dusername, **kwargs) + def _make_filter(self, term, user): if term.startswith("age:"): cond =3D term[term.find(":") + 1:] @@ -240,6 +258,16 @@ Search text keyword in the email message. Example: return self._make_filter_result(term[8:], results__status=3DRe= sult.PENDING) elif term.startswith("running:"): return self._make_filter_result(term[8:], results__status=3DRe= sult.RUNNING) + return self._make_filter_result(cond[8:], results__status=3DRe= sult.RUNNING) + elif term.startswith("ack:") or term.startswith("accept:") or term= .startswith("accepted:"): + username =3D term[term.find(":") + 1:] + return self._make_filter_review(username, user, review__accept= =3DTrue) + elif term.startswith("nack:") or term.startswith("reject:") or ter= m.startswith("rejected:"): + username =3D term[term.find(":") + 1:] + return self._make_filter_review(username, user, review__accept= =3DFalse) + elif term.startswith("review:") or term.startswith("reviewed:"): + username =3D term[term.find(":") + 1:] + return self._make_filter_review(username, user) elif term.startswith("project:"): cond =3D term[term.find(":") + 1:] self._projects.add(cond) diff --git a/mods/maintainer.py b/mods/maintainer.py index e25d8e2..7cb23d2 100644 --- a/mods/maintainer.py +++ b/mods/maintainer.py @@ -12,13 +12,27 @@ from django.conf.urls import url from django.http import Http404, HttpResponseRedirect from django.urls import reverse from mod import PatchewModule -from api.models import Message +from api.models import Message, Review =20 class MaintainerModule(PatchewModule): """ Project maintainer related tasks """ =20 name =3D "maintainer" =20 + def _update_review_state(self, request, message_id, accept): + msg =3D Message.objects.find_series(message_id) + r =3D Review.objects.filter(user=3Drequest.user, message=3Dmsg) + r =3D r[0] if r else Review(user=3Drequest.user, message=3Dmsg) + r.accept =3D accept + r.save() + return HttpResponseRedirect(request.META.get('HTTP_REFERER')) + + def _delete_review(self, request, message_id): + msg =3D Message.objects.find_series(message_id) + r =3D Review.objects.filter(user=3Drequest.user, message=3Dmsg) + r.delete() + return HttpResponseRedirect(request.META.get('HTTP_REFERER')) + def _update_merge_state(self, request, message_id, is_merged): s =3D Message.objects.find_series(message_id) if not s: @@ -35,6 +49,15 @@ class MaintainerModule(PatchewModule): def www_view_clear_merged(self, request, message_id): return self._update_merge_state(request, message_id, False) =20 + def www_view_mark_accepted(self, request, message_id): + return self._update_review_state(request, message_id, True) + + def www_view_mark_rejected(self, request, message_id): + return self._update_review_state(request, message_id, False) + + def www_view_clear_reviewed(self, request, message_id): + return self._delete_review(request, message_id) + def www_url_hook(self, urlpatterns): urlpatterns.append(url(r"^mark-as-merged/(?P.*)/", self.www_view_mark_as_merged, @@ -42,18 +65,59 @@ class MaintainerModule(PatchewModule): urlpatterns.append(url(r"^clear-merged/(?P.*)/", self.www_view_clear_merged, name=3D"clear-merged")) + urlpatterns.append(url(r"^mark-as-accepted/(?P.*)/", + self.www_view_mark_accepted, + name=3D"mark-as-accepted")) + urlpatterns.append(url(r"^mark-as-rejected/(?P.*)/", + self.www_view_mark_rejected, + name=3D"mark-as-rejected")) + urlpatterns.append(url(r"^clear-reviewed/(?P.*)/", + self.www_view_clear_reviewed, + name=3D"clear-reviewed")) =20 def prepare_message_hook(self, request, message, detailed): - if not detailed: + if not detailed or not request.user.is_authenticated: return - if message.is_series_head and request.user.is_authenticated: + if message.is_series_head: if message.is_merged: message.extra_ops.append({"url": reverse("clear-merged", kwargs=3D{"messag= e_id": message.message_id}), - "icon": "times", + "icon": "eraser", "title": "Clear merged state"}) else: message.extra_ops.append({"url": reverse("mark-as-merged", kwargs=3D{"messag= e_id": message.message_id}), "icon": "check", "title": "Mark series as merged"= }) + + r =3D Review.objects.filter(user=3Drequest.user, message=3Dmessage) + if not r or not r[0].accept: + if message.is_series_head: + message.extra_ops.append({"url": reverse("mark-as-accepted= ", + kwargs=3D{"messag= e_id": message.message_id}), + "icon": "check", + "title": "Mark series as accepte= d"}) + else: + message.extra_status.append({ + "icon": "fa-check", + "html": 'The series is marked for merging' + }) + + if not r or r[0].accept: + if message.is_series_head: + message.extra_ops.append({"url": reverse("mark-as-rejected= ", + kwargs=3D{"messag= e_id": message.message_id}), + "icon": "times", + "title": "Mark series as rejecte= d"}) + else: + message.extra_status.append({ + "icon": "fa-times", + "html": 'The series is marked as rejected' + }) + + print(r) + if r: + message.extra_ops.append({"url": reverse("clear-reviewed", + kwargs=3D{"message_id= ": message.message_id}), + "icon": "eraser", + "title": "Clear review state"}) diff --git a/static/css/base.css b/static/css/base.css index 7fe45e4..9e04f50 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -137,7 +137,7 @@ h1, h2, h3, .h1, .h2, .h3 { .status-content > .fa { color: #337ab7; } -.status-content > .fa-warning { +.status-content > .fa-warning, .status-content > .fa-times { color: #CC0000; } .status-content > .fa-check { --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel