From nobody Tue May 13 15:40:04 2025 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 1538145958789339.6362234698562; Fri, 28 Sep 2018 07:45:58 -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 83BB43082A2F; Fri, 28 Sep 2018 14:45:57 +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 6A4E065963; Fri, 28 Sep 2018 14:45:57 +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 5B91D18005CD; Fri, 28 Sep 2018 14:45:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjsYS024612 for ; Fri, 28 Sep 2018 10:45:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7884B600CC; Fri, 28 Sep 2018 14:45:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70BB0600C1 for ; Fri, 28 Sep 2018 14:45:52 +0000 (UTC) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 642C3307D857 for ; Fri, 28 Sep 2018 14:45:51 +0000 (UTC) Received: by mail-wm1-f49.google.com with SMTP id s12-v6so2512958wmc.0 for ; Fri, 28 Sep 2018 07:45:51 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:48 -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=gKWvn2Vm360TYtdvtBk0tUFdU11CtIZ3g1iMTo0WFfg=; b=S5GmInsN5pO4JbuT7yEu98/Lzeq2/kpSdL+UTv+bPbdIuXay1fNjr+QqwDDA7ypjGk GDPT0QRPN0wkD3gK9A96ytrk2m4EvxTq+BypHy7LpwixiOcEoHYKGx254VHnjPtN/kin UK9asr7heY3eTiVrXppe3Ux3XunoX/mu80AXQrGjyKpc8/CJYc+KdtjP0c+8pkw4yxCS W8hfHlAjz9OR4MH2lJY9VMeIOF5V/M2trGu7bIQh4g6VK8gN4g/znLj2heNWAFr+03Wm PvyXoBc0+BfCgoWnDESQHjRlqPdHcEfisV/rUMyizRSjcFFPzdQHFclI0QcIar0sBsrR xj/g== 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=gKWvn2Vm360TYtdvtBk0tUFdU11CtIZ3g1iMTo0WFfg=; b=fOVRg3Rn4ZX9ju9SGrXXXTjt8+AxlZvUgSYkmFjxgwmpLnxy8sdVImrSpbbQ4j9p7V mtX6kjVwpZnZBU6wExV3b02HDHszWrITviUR/7VPvHYyjSktwr9HMC31bSlz57NIXnrv YsQkfqBT0JAuw8PyRe+5k3LY5H+mjb6Vdso6pxKErc1OWX8mI+jEgWQBb3RgS0iFtsQt oxdhSSwTIcZU+2A3L1lmp1d2ci1Yc+tnBUX24q2tBZx8F3pbAN3nmnGA3tVowkszj/d0 NtBPI8tTElzwKUAyFDGRMQONiguTnkTPQZ6WEjRrXH70mLCMUWOkF8rj1SFf47lk9wPt toYQ== X-Gm-Message-State: ABuFfohOocStc/KMpOQCxx3rKymbkQ0fTV8Rvf+Ly7bjE1rZqlGVeYcV ajB85Nhmo/PSCOJmE0a80GOrCvRSzqQ= X-Google-Smtp-Source: ACcGV62etz5Ny42Y14/FKzbMqrIOkW1pWekfqf9sYCXSu07xVseOvbz/ljWLzhW27X8qNzMCQtjfGw== X-Received: by 2002:a1c:f312:: with SMTP id q18-v6mr1806699wmq.14.1538145949656; Fri, 28 Sep 2018 07:45:49 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:35 +0200 Message-Id: <20180928144537.5051-9-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 28 Sep 2018 14:45:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 28 Sep 2018 14:45:51 +0000 (UTC) for IP:'209.85.128.49' DOMAIN:'mail-wm1-f49.google.com' HELO:'mail-wm1-f49.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.489 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.128.49 mail-wm1-f49.google.com 209.85.128.49 mail-wm1-f49.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 08/10] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 28 Sep 2018 14:45:57 +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 | 11 ++++++----- api/views.py | 4 ++-- mods/testing.py | 2 +- www/views.py | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/api/rest.py b/api/rest.py index 9a8ec1e..8789e25 100644 --- a/api/rest.py +++ b/api/rest.py @@ -344,7 +344,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 a2644c5..cf3c145 100644 --- a/api/search.py +++ b/api/search.py @@ -219,7 +219,7 @@ Search text keyword in the email message. Example: return Q(is_merged=3DTrue) return None =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) @@ -268,7 +268,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, term): + def _process_term(self, term, user): """ Return a Q object that will be applied to the query """ is_plusminus =3D neg =3D False if term[0] in "+-!": @@ -279,7 +279,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 ~q else: @@ -291,11 +291,12 @@ 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() q =3D reduce(lambda x, y: x & y, - map(lambda t: self._process_term(t), terms), Q()) + map(lambda t: self._process_term(t, user), terms), + Q()) if queryset is None: queryset =3D Message.objects.series_heads() return queryset.filter(q) 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 58f9de7..2fd7d1e 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -517,6 +517,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