From nobody Fri Apr 19 21:25:23 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 1527595573369311.3563468737592; Tue, 29 May 2018 05:06:13 -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 B2C0E641C5; Tue, 29 May 2018 12:06:11 +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 9FC2E3083327; Tue, 29 May 2018 12:06:11 +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 52F5A1800C99; Tue, 29 May 2018 12:06:11 +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 w4TC69m1006346 for ; Tue, 29 May 2018 08:06:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 40A85981B1; Tue, 29 May 2018 12:06:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3519E1BBC3 for ; Tue, 29 May 2018 12:05:55 +0000 (UTC) Received: from mail-pl0-f42.google.com (mail-pl0-f42.google.com [209.85.160.42]) (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 CC054641C5 for ; Tue, 29 May 2018 12:05:43 +0000 (UTC) Received: by mail-pl0-f42.google.com with SMTP id c11-v6so8826632plr.5 for ; Tue, 29 May 2018 05:05:43 -0700 (PDT) Received: from localhost.localdomain ([182.74.40.122]) by smtp.gmail.com with ESMTPSA id u9-v6sm78187794pfj.10.2018.05.29.05.05.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:05:41 -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; bh=95w58y2r4zVxw7TdzeyknUzs/T9Q9gmMHbSBO2r7xsA=; b=n64l+pw4Sx+G5/51EoXWAceXT12i+FtSP42XSxMwZ0YgTJ2yLxfSwj3L6Cb1hxJ7px ympdOCEK6HS14oz5E0gr/TQxxpOfwUEI6DNq9erpMui2iv+eBwOYn8oDOK/FTYJsw9X/ NSlp0rzAf0x8ggngvZLYWvMsuTGXVqNhTUevKGFM0vNOSWPsO3KGdWHi5ct+kp3TG/Ak M3aRae8UyNLimmLOofHZ8w1fL9EuKVMSSoCP8nOtetxtikwyTGL9zIfTxE+Q3aVxE8jo jPOC+WWSAj7odrLgTJREaqOn+WB5q57gR9Bqlndimx/or2ENa//TPbSST3njLhzlB0fj WEXA== 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; bh=95w58y2r4zVxw7TdzeyknUzs/T9Q9gmMHbSBO2r7xsA=; b=dvUwkwI63FQhIGTcyFiEHLKVD7A+NLT9ekMzw06i9HO+04ysfqPJQnG0hqgg20zS4q 2Ok4bca5hCJFwVAtjVAwy9J27qPskVf6tT2LWPFpkhJsy9Z6dEpslgEJgojQwMhbv/CW D+fAEQ6ixMpvYQWncbXmbMH09UDzCjbijL9xtFD2QvQyyxS6aeWEf8I+UhFtqiSJLy2P qZb2sDkHvp1XOUzkw727OyU3qPkxf1EzceeDzsGTH75nkHSb4qOD1q2R9tq4CWYU81yd 99tVcRUTT3X/hj4w3x+576biZ3edr6y5XwfIzAF6JhhKgHFnpzE0mjRDLhPT1T7RiB7M hrfg== X-Gm-Message-State: ALKqPweW2+BkcVb5ZGo6EN3ryJKDHlfWYLvFGmTjmig/BsrKjyI1y4OI SpvYY+Aggy8rA9Cj0IfNqvzu+g== X-Google-Smtp-Source: AB8JxZp7oJ4lBVDg5DV2cg9aD0CsA48YU1y+G+0UZvmZv9crgM/ftB7/bpYt+ii7ak+AERd/1O2I2A== X-Received: by 2002:a17:902:6105:: with SMTP id t5-v6mr17240285plj.138.1527595542759; Tue, 29 May 2018 05:05:42 -0700 (PDT) From: Shubham To: patchew-devel@redhat.com Date: Tue, 29 May 2018 17:35:32 +0530 Message-Id: <20180529120532.4246-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 29 May 2018 12:05:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 29 May 2018 12:05:43 +0000 (UTC) for IP:'209.85.160.42' DOMAIN:'mail-pl0-f42.google.com' HELO:'mail-pl0-f42.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) 209.85.160.42 mail-pl0-f42.google.com 209.85.160.42 mail-pl0-f42.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 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] 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 29 May 2018 12:06:12 +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: Wingify 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 | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/api/rest.py b/api/rest.py index fa6ca3f..e9282c3 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,29 @@ 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 old_head_0 and old_head_0 !=3D old_head: + raise Exception("wrong old head") + ret =3D project.series_update(message_ids) + project.project_head =3D request.data['new_head'] + Response({"new_head": project.project_head, "count": ret}) + else: + return Response({'project_head': head}) # Common classes for series and messages =20 class HyperlinkedMessageField(HyperlinkedIdentityField): --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel