From nobody Tue May 13 13:16:11 2025 Delivered-To: importer2@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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1557925121; cv=none; d=zoho.com; s=zohoarc; b=OS0J3I/bFesjNFBW/j29ukBj5kpYKLpJ/KOLs+shRwpOt/9iCdvo0NoAI0Ax7D7RR3iH9knUeCdXwPmjaUlVe5/X7gDg0Kh9m27chiSkVh4+sKjwyaSWKMggMv3pYIkoXv/5qpo4QWooui+nAeq5m6JYLVhWYWE2rLZNjBeykWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557925121; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sHQVjWMrmwZJGC0CSi3A5+N3Y7BukMwKqOBQ95KiYbQ=; b=EAxXQuITI6AGSnQc1luT9V+m8CKlz3hBMNR0Lzv1Bq+Zz5aiK36rvnmunm2piLuJpnYVcL1rHa3DQOupvdTjxtL/8kiJ0WeekcGVzD6SUXNQSnf/Uri1Q/hxs7Mx3w/v9GtiUBlMLZGG3YKFsBFQkB3WIhXjCoc+edVqtrlfiZk= ARC-Authentication-Results: i=1; mx.zoho.com; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1557925121985931.472659931754; Wed, 15 May 2019 05:58:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DEE13083394; Wed, 15 May 2019 12:58:40 +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 82DCF608AB; Wed, 15 May 2019 12:58:40 +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 784584BB43; Wed, 15 May 2019 12:58:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4FCwc5N012673 for ; Wed, 15 May 2019 08:58:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id A5DCA60CDA; Wed, 15 May 2019 12:58:38 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-34.ams2.redhat.com [10.36.112.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0686460CC0 for ; Wed, 15 May 2019 12:58:35 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Wed, 15 May 2019 14:58:02 +0200 Message-Id: <20190515125808.27716-6-pbonzini@redhat.com> In-Reply-To: <20190515125808.27716-1-pbonzini@redhat.com> References: <20190515125808.27716-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 05/11] git, rest: add mbox URI to API replies 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: , 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 15 May 2019 12:58:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Once this API is deployed, this will let us remove the filter-branch code from the applier. Instead, collecting tags reuses the existing code in www/urls.py. --- api/rest.py | 38 ++++++++++++++++++++++++-------------- mods/git.py | 7 +++++++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/api/rest.py b/api/rest.py index e64c828..9525a27 100644 --- a/api/rest.py +++ b/api/rest.py @@ -29,6 +29,20 @@ from rest_framework.parsers import BaseParser =20 SEARCH_PARAM =3D 'q' =20 + +class StaticTextRenderer(renderers.BaseRenderer): + media_type =3D 'text/plain' + format =3D 'mbox' + + def render(self, data, accepted_media_type=3DNone, renderer_context=3D= None): + renderer_context =3D renderer_context or {} + response =3D renderer_context.get('response') + if response and response.exception: + return '%d %s' % (response.status_code, response.status_text.t= itle()) + else: + return data + + # patchew-specific permission classes =20 =20 @@ -361,13 +375,14 @@ class SeriesSerializer(BaseMessageSerializer): class Meta: model =3D Message subclass_read_only_fields =3D ('message', 'stripped_subject', 'num= _patches', - 'total_patches', 'results') + 'total_patches', 'results', 'mbox_uri') fields =3D BaseMessageSerializer.Meta.fields + subclass_read_only_= fields + ( 'last_comment_date', 'last_reply_date', 'is_complete', 'is_mer= ged', 'is_obsolete', 'is_tested', 'is_reviewed', 'maintainers') read_only_fields =3D BaseMessageSerializer.Meta.read_only_fields += subclass_read_only_fields =20 resource_uri =3D HyperlinkedMessageField(view_name=3D'series-detail') + mbox_uri =3D HyperlinkedMessageField(view_name=3D'series-mbox') message =3D HyperlinkedMessageField(view_name=3D'messages-detail') results =3D HyperlinkedMessageField(view_name=3D'results-list', lookup= _field=3D'series_message_id') total_patches =3D SerializerMethodField() @@ -474,6 +489,14 @@ class ProjectSeriesViewSet(ProjectMessagesViewSetMixin, def perform_destroy(self, instance): Message.objects.delete_subthread(instance) =20 + @action(detail=3DTrue, renderer_classes=3D[StaticTextRenderer]) + def mbox(self, request, *args, **kwargs): + message =3D self.get_object() + mbox =3D message.get_mbox_with_tags() + if not mbox: + raise Http404("Series not complete") + return Response(mbox) + =20 # Messages =20 @@ -506,19 +529,6 @@ class MessageCreationSerializer(BaseMessageSerializer): =20 mbox =3D CharField() =20 -class StaticTextRenderer(renderers.BaseRenderer): - media_type =3D 'text/plain' - format =3D 'mbox' - - def render(self, data, accepted_media_type=3DNone, renderer_context=3D= None): - renderer_context =3D renderer_context or {} - response =3D renderer_context.get('response') - if response and response.exception: - return '%d %s' % (response.status_code, response.status_text.t= itle()) - else: - return data - - class MessagePlainTextParser(BaseParser): media_type =3D 'message/rfc822' =20 diff --git a/mods/git.py b/mods/git.py index 6135f28..42a932e 100644 --- a/mods/git.py +++ b/mods/git.py @@ -12,6 +12,7 @@ import os import subprocess import hashlib import json +import rest_framework from django.conf.urls import url from django.http import Http404, HttpResponseRedirect from django.urls import reverse @@ -275,6 +276,12 @@ class ApplierGetView(APILoginRequiredView): response["git.repo"] =3D base.data["repo"] response["git.base"] =3D base.data["tag"] response["project.git"] =3D po.git + response["mbox_uri"] =3D rest_framework.reverse.reverse("series-mb= ox", + kwargs=3D{ + 'project= s_pk': m.project_id, + 'message= _id': m.message_id, + }, + request=3Dre= quest) response["result_uri"] =3D reverse_detail(m.git_result, request) return response =20 --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel