From nobody Sat Apr 20 09:22:16 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1527825331835771.3138231013842; Thu, 31 May 2018 20:55:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1003CC307; Fri, 1 Jun 2018 03:55:30 +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 B446E17F88; Fri, 1 Jun 2018 03:55:30 +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 A69031809547; Fri, 1 Jun 2018 03:55:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w513tUDx022728 for ; Thu, 31 May 2018 23:55:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E07D100194F; Fri, 1 Jun 2018 03:55:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65EC21001947 for ; Fri, 1 Jun 2018 03:55:28 +0000 (UTC) Received: from mail-pg0-f50.google.com (mail-pg0-f50.google.com [74.125.83.50]) (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 EF72630CADED for ; Fri, 1 Jun 2018 03:55:16 +0000 (UTC) Received: by mail-pg0-f50.google.com with SMTP id e11-v6so1446407pgq.0 for ; Thu, 31 May 2018 20:55:16 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.29]) by smtp.gmail.com with ESMTPSA id f9-v6sm52384947pgq.24.2018.05.31.20.55.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 20:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lnQv2XcDTyW7F64mphBy5rRntjuac33B61Tb7HoFc98=; b=T0dwwQpeAUeP75ZPXNuD25IH3QIIEqolBfKB9KEiqDBIyMeqjdfHE2iVxbMYOahoZ7 xMogHxbrgzeOfUKTRJBzm6Vn85VjKBcwMR7fSMIVOCTCn7sUxsYxMCHornPZzcjIuhNP J79khg9T47zi7ZmVwENCqHRv3fw6RCe2hnCZs4E16ubuzgo2LNKA5xN9qW8ZoNbMVwIn 1QUjcf3oWIsnpewiyYrC5p3ddApP39mE3qalPJ+yEdF3xSALRNAHLBZuhFTGHpayZd5+ gfcFKEJML6cnAKGTD6fViRZSD6xAv7LFoEzWCS00gX5Co13NwO1kIEpp3sPacd/noawK 3jNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lnQv2XcDTyW7F64mphBy5rRntjuac33B61Tb7HoFc98=; b=XCj5JS/icLAR02/xEZJ6/WjH/3ZnSJK56fKyegj2EK2fKhuscOIZ2WFSVsIL4ndyPh HBdtlVhGDIRIXzpTAENsUSwXtMoTsthOXk50x3PLuBWjG2RqZ1OIL7uTxs+1fJQW2ok0 7BY8zqgY7orG8v6nmvxHgL4YP76jJrKfA1aVvsIUMoHUdqrnMCUNJoSPNw7TaxXrbGEi 6CififkuYOy8Asp/r6QfZrYVNxs2/Mb+NdinTcqM+nez6AAqfWJ7BWOSeiJT9eXSNsp9 GX1egg5r64adtG6BXSF6DGf4eCk8hthWOk0/taYg3/MF6pVBaQ6+XK6UIvd8uTywAdbb hsdw== X-Gm-Message-State: ALKqPwck4T1Pety1eUoChL4fsAPwxWGFQZhGBmZ0c4cyEJ91ZA0/rSym pgYLzzxHbCjWPHnbbkx/El0o7A== X-Google-Smtp-Source: ADUXVKKMiM+1vcEZbXcKqEIpJKwhWHymB3dGoBYEMzVy0HSD1TtYvCnssAaMj548OSLNxC/84/yD+A== X-Received: by 2002:a63:3dcc:: with SMTP id k195-v6mr7542431pga.254.1527825315719; Thu, 31 May 2018 20:55:15 -0700 (PDT) From: cic To: patchew-devel@redhat.com Date: Fri, 1 Jun 2018 09:24:38 +0530 Message-Id: <1527825279-10484-2-git-send-email-shubhamjain7495@gmail.com> In-Reply-To: <1527825279-10484-1-git-send-email-shubhamjain7495@gmail.com> References: <1527825279-10484-1-git-send-email-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 01 Jun 2018 03:55:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 01 Jun 2018 03:55:17 +0000 (UTC) for IP:'74.125.83.50' DOMAIN:'mail-pg0-f50.google.com' HELO:'mail-pg0-f50.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.551 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.50 mail-pg0-f50.google.com 74.125.83.50 mail-pg0-f50.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: patchew-devel@redhat.com Cc: shubhamjain7495@gmail.com Subject: [Patchew-devel] [PATCH 1/2] rest: Add endpoint from update-project-head 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 01 Jun 2018 03:55:30 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Shubham Added extra action in the ProjectViewSet which will update the project head= at endpoint /projects/../update_project_head. This is legacy conversion(Up= dateProjectHeadView) into rest --- api/rest.py | 26 +++++++++++++++++++++++++- tests/test_rest.py | 18 ++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/api/rest.py b/api/rest.py index fa6ca3f..d62a144 100644 --- a/api/rest.py +++ b/api/rest.py @@ -18,7 +18,7 @@ from .models import Project, Message from .search import SearchEngine from rest_framework import (permissions, serializers, viewsets, filters, mixins, generics, renderers, status) -from rest_framework.decorators import detail_route +from rest_framework.decorators import detail_route, action from rest_framework.fields import SerializerMethodField, CharField, JSONFi= eld, EmailField from rest_framework.relations import HyperlinkedIdentityField from rest_framework.response import Response @@ -141,6 +141,30 @@ class ProjectsViewSet(viewsets.ModelViewSet): serializer_class =3D ProjectSerializer permission_classes =3D (PatchewPermission,) =20 + @action(methods=3D['post','get'], detail=3DTrue, permission_classes=3D= [ImportPermission]) + def update_project_head(self, request, pk=3DNone): + """ + updates the project head and message_id which are matched are merg= ed.=20 + Data input format: + { + "old_head": "..", + "new_head": "..", + "message_ids": [] + } + """ + project =3D self.get_object() + head =3D project.project_head + if request.method =3D=3D 'POST': + old_head =3D request.data['old_head'] + message_ids =3D request.data['message_ids'] + if head and head !=3D old_head: + raise Exception("wrong old head") + ret =3D project.series_update(message_ids) + project.project_head =3D request.data['new_head'] + return Response({"new_head": project.project_head, "count": re= t}) + else: + return Response({'project_head': head}) + # Common classes for series and messages =20 class HyperlinkedMessageField(HyperlinkedIdentityField): diff --git a/tests/test_rest.py b/tests/test_rest.py index 1399801..2a85815 100755 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -86,6 +86,24 @@ class RestTest(PatchewTestCase): self.assertEquals(resp.data['mailing_list'], "qemu-block@nongnu.or= g") self.assertEquals(resp.data['parent_project'], self.PROJECT_BASE) =20 + def test_update_project_head(self): + resp =3D self.apply_and_retrieve('0001-simple-patch.mbox.gz', + self.p.id, '20160628014747.20971-1-= famz@redhat.com') + self.api_client.login(username=3Dself.user, password=3Dself.passwo= rd) =20 + resp_before =3D self.api_client.get(self.PROJECT_BASE + "series/"+= "20160628014747.20971-1-famz@redhat.com/") + data =3D { + "message_ids": ["20160628014747.20971-1-famz@redhat.com"], + "old_head": "None", + "new_head": "000000" + } + resp =3D self.api_client.post(self.PROJECT_BASE + "update_project_= head/", data=3Djson.dumps(data), content_type=3D'application/json') + resp_after =3D self.api_client.get(self.PROJECT_BASE + "series/"+ = "20160628014747.20971-1-famz@redhat.com/") + self.assertEquals(resp_before.data['is_merged'], False) + self.assertEquals(resp.status_code, 200) + self.assertEquals(resp.data['count'], 1) + self.assertEquals(resp.data['new_head'], "000000") + self.assertEquals(resp_after.data['is_merged'], True) + def test_project_post_no_login(self): data =3D { 'name': 'keycodemapdb', --=20 1.9.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sat Apr 20 09:22:16 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1527825338869835.519320548833; Thu, 31 May 2018 20:55:38 -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 DBA61D64A2; Fri, 1 Jun 2018 03:55:37 +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 CB91617120; Fri, 1 Jun 2018 03:55:37 +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 BD3864CA81; Fri, 1 Jun 2018 03:55:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w513tbK5022741 for ; Thu, 31 May 2018 23:55:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4064191D1A; Fri, 1 Jun 2018 03:55:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 38EDF9B040 for ; Fri, 1 Jun 2018 03:55:35 +0000 (UTC) Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.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 B8C353006029 for ; Fri, 1 Jun 2018 03:55:24 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id e11-v6so1446537pgq.0 for ; Thu, 31 May 2018 20:55:24 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.29]) by smtp.gmail.com with ESMTPSA id f9-v6sm52384947pgq.24.2018.05.31.20.55.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 20:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+Cab+h0/OzZKriEv4OY2m7ldO8nrUfZ2g2/jmRrpHCQ=; b=Y8+GJiiX+I25sU8OEVsFqBJ5s0Y9X0MA+xxvR8D3dEYbZ5faID1LLTFper+5PI8xr2 ki7NboBaUnmvjT/Hi8/ggpshNzovJsfiVBiH5wgPK30TOGSrvt7oWM6vvjLYD3rO+FJs x24bBV/pnLjnXRxv3I+2Pi1mTO75HGnH1BJPJtsnDpTpeEDk6K6WYa8Gp2lhrnH2/lQG ETUrzIyd8Cv96kwOTv69JMO/eKYnFFso35edmZXAfYXpqeReWR18OXRByJ7hoR8EopUw JwihvGciOiyB96vAZFkxvyuJtmV4Y0gIi2BMHoKvhx26LMkCm/GQ1CNNPNfgmhS4sW4K sCZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+Cab+h0/OzZKriEv4OY2m7ldO8nrUfZ2g2/jmRrpHCQ=; b=Pjy/+NpsAsUqkZhCOE1VPiMXikqaGgz15/M80QsCVUsnRme7AIZ/B4isuntTBZpHQO iarxCTd1nPmx9Lv7QRiQowHWANqbzW3gL4p9sIANdSsIv2ffzZNoosea8Pv+0yaeTxoX kfzKXCMAfu+AkM5BkajNMxnqiVivGGbaq6ZCe2mxhNS/FH92HosIok9fgbwL/1HzwJj2 YGGhM6Wb4iD8fv5F+fMpJnDTNaWUBo1H1DFH0+LaeJXQ0teAvtCo1uCeE8/NraqH6C7L g97iioLVgazoNvk9dRMebL5ssc8PzzDg94jVw67j+8NQp7oUnIeL8WJLNQOvVbWskeT6 ZG1w== X-Gm-Message-State: ALKqPweqxdUZMaom3neXp0E+239cQdQGU7k4z9LQOyOtaZnh1/QJq5Cq F5t4w3t4L6H2KB9y7h+IM56VRA== X-Google-Smtp-Source: ADUXVKKkp7C+Y4DuzdY8JDLPHOdN26hAQh9dAkJbv473Jny8J4BexMuHG1quwHzjlGzeYzZeKMWuow== X-Received: by 2002:a62:f713:: with SMTP id h19-v6mr9179210pfi.165.1527825323732; Thu, 31 May 2018 20:55:23 -0700 (PDT) From: cic To: patchew-devel@redhat.com Date: Fri, 1 Jun 2018 09:24:39 +0530 Message-Id: <1527825279-10484-3-git-send-email-shubhamjain7495@gmail.com> In-Reply-To: <1527825279-10484-1-git-send-email-shubhamjain7495@gmail.com> References: <1527825279-10484-1-git-send-email-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 01 Jun 2018 03:55:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 01 Jun 2018 03:55:24 +0000 (UTC) for IP:'74.125.83.67' DOMAIN:'mail-pg0-f67.google.com' HELO:'mail-pg0-f67.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.531 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.83.67 mail-pg0-f67.google.com 74.125.83.67 mail-pg0-f67.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: patchew-devel@redhat.com Cc: shubhamjain7495@gmail.com Subject: [Patchew-devel] [PATCH 2/2] model: fixed variable name 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.26]); Fri, 01 Jun 2018 03:55:37 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Shubham fixed variable name from s to series in series_update() --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index e3585e4..b4f8468 100644 --- a/api/models.py +++ b/api/models.py @@ -193,7 +193,7 @@ class Project(models.Model): s =3D mo.get_series_head() if s: updated_series.append(s) - for s in updated_series: + for series in updated_series: for p in series.get_patches(): if not p.is_merged: break --=20 1.9.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel