From patchwork Tue May 10 22:39:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Doan X-Patchwork-Id: 620854 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.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r4DkS5c9Hz9s2G for ; Wed, 11 May 2016 08:41:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=FKW4y8h3; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3r4DkS2Jj0zDq64 for ; Wed, 11 May 2016 08:41:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=FKW4y8h3; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mail-oi0-x236.google.com (mail-oi0-x236.google.com [IPv6:2607:f8b0:4003:c06::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3r4Dhk10DNzDqBY for ; Wed, 11 May 2016 08:39:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=FKW4y8h3; dkim-atps=neutral Received: by mail-oi0-x236.google.com with SMTP id v145so40083474oie.0 for ; Tue, 10 May 2016 15:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xrYYSVkFn4WB9WQmzXGbHzo0jW6B9O5Y0Xb8W7Q7q8k=; b=FKW4y8h3tNM3sVFfaZfDquVcTZRsxy1TFhOKQgQypprp0GdhEzc8aULuBRfG4DFZyk pYMdnjaVilvdQdHN83sBS7/rMy/tuv8I/sfgZ0mpm226MidyFFYFwrczVDwnwEHOVili a/8w8sDt1EMX6j36mg+YySsG2lDdQ9zqFBkoE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xrYYSVkFn4WB9WQmzXGbHzo0jW6B9O5Y0Xb8W7Q7q8k=; b=UjGSNU4ZGbhCuLQ2J5iCOS46jAYiBwIXil7qXQSYvbq5zv34xtnBkMhtUbnGjNYklh yusQNMeV8gYO3Ja2VdsgfQ8/Cs+H7QUbaoroEa+OKk1iwYKNVSJzIn0HF290bUjgLw32 qkFUGHcotUvwGNg5U2mScLlKmVagRnvK0XPpA5jsY2RL0+mH6mml8WSWGyYnH7p0iOJs q6YYf3GDmM/IxCt/gjLx9QNmLeZkeW5Rpcx9F2ehzLcQLnGF+aygIA2Bdbe15aUmlxbU EXnqWOUFa8LF/pB5O9Mch73Y+kT1nWb+Q5heg5W0P/g6IqdPg0132P5wqEoPymP4ZKfG yrTA== X-Gm-Message-State: AOPr4FWryhOaBGdUBKU/+NY6CvlunG0hGS6pxevGymBw58IEhwpF0V3Ybai6x9W1Grp/MvcC X-Received: by 10.157.63.70 with SMTP id m64mr20896otc.170.1462919988176; Tue, 10 May 2016 15:39:48 -0700 (PDT) Received: from doanac-xps.local (cpe-70-117-126-139.austin.res.rr.com. [70.117.126.139]) by smtp.gmail.com with ESMTPSA id sl9sm1223255oeb.10.2016.05.10.15.39.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 May 2016 15:39:47 -0700 (PDT) From: Andy Doan To: patchwork@lists.ozlabs.org Subject: [PATCHv2 07/10] REST: Add Patch.mbox_url Date: Tue, 10 May 2016 17:39:24 -0500 Message-Id: <1462919967-26088-8-git-send-email-andy.doan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462919967-26088-1-git-send-email-andy.doan@linaro.org> References: <1462919967-26088-1-git-send-email-andy.doan@linaro.org> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Provide a URL to the raw patch. This removes previous functionality added to create_model_serializer thats no longer needed. Signed-off-by: Andy Doan Reviewed-by: Stephen Finucane --- patchwork/models.py | 4 ++++ patchwork/rest_serializers.py | 7 ++++++- patchwork/tests/test_rest_api.py | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/patchwork/models.py b/patchwork/models.py index 6324273..6209527 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -458,6 +458,10 @@ class Patch(Submission): def get_absolute_url(self): return ('patch-detail', (), {'patch_id': self.id}) + @models.permalink + def get_mbox_url(self): + return ('patch-mbox', (), {'patch_id': self.id}) + def __str__(self): return self.name diff --git a/patchwork/rest_serializers.py b/patchwork/rest_serializers.py index b39c8f4..6760948 100644 --- a/patchwork/rest_serializers.py +++ b/patchwork/rest_serializers.py @@ -20,7 +20,8 @@ from patchwork.models import Check, Patch, Person, Project from rest_framework.serializers import ( - CurrentUserDefault, ModelSerializer, HiddenField, PrimaryKeyRelatedField) + CurrentUserDefault, ModelSerializer, HiddenField, PrimaryKeyRelatedField, + SerializerMethodField) class PersonSerializer(ModelSerializer): @@ -38,6 +39,10 @@ class PatchSerializer(ModelSerializer): model = Patch read_only_fields = ('project', 'name', 'date', 'submitter', 'diff', 'content', 'hash', 'msgid') + mbox_url = SerializerMethodField() + + def get_mbox_url(self, patch): + return patch.get_mbox_url() class CurrentPatchDefault(object): diff --git a/patchwork/tests/test_rest_api.py b/patchwork/tests/test_rest_api.py index c81edca..780edd4 100644 --- a/patchwork/tests/test_rest_api.py +++ b/patchwork/tests/test_rest_api.py @@ -195,6 +195,7 @@ class TestPatchAPI(APITestCase): self.assertEqual(patches[0].diff, resp.data['diff']) self.assertEqual(patches[0].submitter.id, resp.data['submitter']) self.assertEqual(patches[0].state.id, resp.data['state']) + self.assertEqual(patches[0].get_mbox_url(), resp.data['mbox_url']) def test_anonymous_writes(self): """Ensure anonymous "write" operations are rejected."""