From patchwork Fri Jun 28 11:43:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mete Polat X-Patchwork-Id: 1124133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Zw124hslz9s3Z for ; Fri, 28 Jun 2019 21:44:54 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pbEcXxen"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45Zw123k6JzDqnv for ; Fri, 28 Jun 2019 21:44:54 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=metepolat2000@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pbEcXxen"; dkim-atps=neutral Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45Zw024cK9zDqlw for ; Fri, 28 Jun 2019 21:43:59 +1000 (AEST) Received: by mail-wm1-x341.google.com with SMTP id c6so8705115wml.0 for ; Fri, 28 Jun 2019 04:43:59 -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 :mime-version:content-transfer-encoding; bh=cVT/ygITd6i13GiJB3BJEbImVggPSXNjDWzjWTYTB/M=; b=pbEcXxenRJDH7M2N1ETfKZrLEWLZX9Neh5KcqdzwaCrR/Qi/+/j+pe8Rh22gYxYTl9 LHr9+HFimVH+1phLlmg9FEFuvg8PCU2sW2dZnDY3Gm2eMMF33EugzgM6SEk3GVgEeXW4 l8ScOpnp1Q1jhqxr7qa0A8vWoB9wGowAUSR0axbJYs2+fQCW3B86WXYDHRdAy6+wI+ln RxazSUI68eYfd5aGptjJag7wsq7cwrUOASgCXFK4VCmvtZuGjhY6SqixrsUwUklAs8Z6 KJA4roguSWyQC4J0VT6h/4jZLjKnqeZ/dcJHc5UtiBaC0FkEeH+n/PtXk12QydOyqBby LHvg== 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:mime-version:content-transfer-encoding; bh=cVT/ygITd6i13GiJB3BJEbImVggPSXNjDWzjWTYTB/M=; b=Uu1TyDrHMwOZbgeGu6i1nSaZqOglnjPz86/eHhBJ73+/Eq3bqyMyRwvZ95u4yi8PPL qIl7Dg8b0aplw2wf2+yT6BMMkbyPy8R62shDmjfshmAbnuxVrrliz4VXGiDdfAWIoWJI YmG3P96bqFcjNx3TExg25x4vj4D3WoBKUyvrT1Flb0nzaCEWlyWLq4izNBPCyke+SgpM EcTj/+icHN2cnCwk7VlZvOzlTwG0hKh/62VIcgNe64iwCySKrhg9UYnxHLiRzeCvpGFa Ptc2+i2CAdt32JHHQ6Bhb58O329uGmXRHk+cSvJU1uTwCrKQnGMUWDTJCC/uZS7H5m+l 545Q== X-Gm-Message-State: APjAAAWI4sr7KcGJdt6HVCCjmSsxb3mZi4e6pvjGxR+7kqvuOUmjJsWb L7PsdfYsmIGpExPqXUHcIAWJbwA1PV9Dcw== X-Google-Smtp-Source: APXvYqxFvGY9MDd+hDJURJm5P8Jjy+VlKncl+58FiSIK7mFn0aZnkkvDxgfH+tXJFs1GjFR04223Pw== X-Received: by 2002:a1c:c74a:: with SMTP id x71mr7040933wmf.121.1561722236443; Fri, 28 Jun 2019 04:43:56 -0700 (PDT) Received: from localhost.localdomain ([193.23.33.53]) by smtp.gmail.com with ESMTPSA id q12sm3258127wrp.50.2019.06.28.04.43.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Jun 2019 04:43:55 -0700 (PDT) From: Mete Polat To: patchwork@lists.ozlabs.org Subject: [PATCH 3/5] Add api endpoint for project patches as mbox Date: Fri, 28 Jun 2019 13:43:12 +0200 Message-Id: <20190628114314.10462-4-metepolat2000@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190628114314.10462-1-metepolat2000@gmail.com> References: <20190628114314.10462-1-metepolat2000@gmail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lukas.bulwahn@gmail.com Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Introduces a new field in the project endpoint called 'patches_mbox'. Signed-off-by: Mete Polat --- Again 'patches_mbox' and not 'mbox' in order to prevent confusion. patchwork/api/project.py | 11 +++++++++-- patchwork/models.py | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/patchwork/api/project.py b/patchwork/api/project.py index d7bb1f2..1f8862d 100644 --- a/patchwork/api/project.py +++ b/patchwork/api/project.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later from django.shortcuts import get_object_or_404 +from rest_framework.fields import SerializerMethodField from rest_framework.generics import ListAPIView from rest_framework.generics import RetrieveUpdateAPIView from rest_framework.serializers import CharField @@ -21,16 +22,22 @@ class ProjectSerializer(BaseHyperlinkedModelSerializer): list_email = CharField(max_length=200, source='listemail', read_only=True) maintainers = UserProfileSerializer(many=True, read_only=True, source='maintainer_project') + patches_mbox = SerializerMethodField() + + def get_patches_mbox(self, instance): + request = self.context.get('request') + return request.build_absolute_uri(instance.get_mbox_url()) class Meta: model = Project fields = ('id', 'url', 'name', 'link_name', 'list_id', 'list_email', 'web_url', 'scm_url', 'webscm_url', 'maintainers', - 'subject_match') + 'subject_match', 'patches_mbox') read_only_fields = ('name', 'link_name', 'list_id', 'list_email', - 'maintainers', 'subject_match') + 'maintainers', 'subject_match', 'patches_mbox') versioned_fields = { '1.1': ('subject_match', ), + '1.2': ('patches_mbox', ), } extra_kwargs = { 'url': {'view_name': 'api-project-detail'}, diff --git a/patchwork/models.py b/patchwork/models.py index 36d6fad..770f572 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -104,6 +104,9 @@ class Project(FilenameMixin, models.Model): return [] return list(Tag.objects.all()) + def get_mbox_url(self): + return reverse('patch-list-mbox', kwargs={'project_id': self.linkname}) + def __str__(self): return self.name