From patchwork Thu Aug 8 02:40:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1143773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 463t1V61swz9s7T for ; Thu, 8 Aug 2019 12:41:50 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 463t1V4shrzDqVZ for ; Thu, 8 Aug 2019 12:41:50 +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=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=ajd@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 463t0B4Z9PzDqV8 for ; Thu, 8 Aug 2019 12:40:42 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x782aV5e048315 for ; Wed, 7 Aug 2019 22:40:39 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2u88vc4hjg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 07 Aug 2019 22:40:39 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Aug 2019 03:40:37 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 8 Aug 2019 03:40:34 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x782eXS546399678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Aug 2019 02:40:33 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FBB611C04C; Thu, 8 Aug 2019 02:40:33 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 97EFC11C04A; Thu, 8 Aug 2019 02:40:32 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 8 Aug 2019 02:40:32 +0000 (GMT) Received: from intelligence.bha-au.ibmmobiledemo.com (unknown [9.102.61.127]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 09F6DA026D; Thu, 8 Aug 2019 12:40:29 +1000 (AEST) From: Andrew Donnellan To: patchwork@lists.ozlabs.org Subject: [PATCH 2/6] models: Add list archive lookup Date: Thu, 8 Aug 2019 12:40:11 +1000 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190808024015.8102-1-ajd@linux.ibm.com> References: <20190808024015.8102-1-ajd@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19080802-0012-0000-0000-0000033C16AF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19080802-0013-0000-0000-00002176175A Message-Id: <20190808024015.8102-2-ajd@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-08-07_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908080026 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: Takashi Iwai Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Add a list_archive_lookup_prefix field to Project, which will contain the address of a Message-ID redirector, e.g. "https://lore.kernel.org/r/". Add a list_archive_url property to Submission and Comment, to generate an archive lookup URL based on the Message-ID. We will use this to display links to mailing list archives. Suggested-by: Takashi Iwai Signed-off-by: Andrew Donnellan --- ...0035_project_list_archive_lookup_prefix.py | 20 ++++++++++++++++ patchwork/models.py | 23 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 patchwork/migrations/0035_project_list_archive_lookup_prefix.py diff --git a/patchwork/migrations/0035_project_list_archive_lookup_prefix.py b/patchwork/migrations/0035_project_list_archive_lookup_prefix.py new file mode 100644 index 000000000000..7d5f94a462a5 --- /dev/null +++ b/patchwork/migrations/0035_project_list_archive_lookup_prefix.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.21 on 2019-07-01 12:57 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('patchwork', '0034_project_list_archive_url'), + ] + + operations = [ + migrations.AddField( + model_name='project', + name='list_archive_lookup_prefix', + field=models.CharField(blank=True, help_text=b"URL prefix for the list archive's Message-ID redirector. To generate the list archive link for a patch, the Message-ID is appended to the end of this prefix.", max_length=2000), + ), + ] diff --git a/patchwork/models.py b/patchwork/models.py index e43b062b6f89..04d87a459e3a 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -78,6 +78,11 @@ class Project(models.Model): scm_url = models.CharField(max_length=2000, blank=True) webscm_url = models.CharField(max_length=2000, blank=True) list_archive_url = models.CharField(max_length=2000, blank=True) + list_archive_lookup_prefix = models.CharField( + max_length=2000, blank=True, + help_text="URL prefix for the list archive's Message-ID redirector. " + "To generate the list archive link for a patch, the Message-ID is " + "appended to the end of this prefix.") # configuration options @@ -358,6 +363,15 @@ class Submission(FilenameMixin, EmailMixin, models.Model): name = models.CharField(max_length=255) + @property + def list_archive_url(self): + if not self.project.list_archive_lookup_prefix: + return None + if not self.msgid: + return None + return self.project.list_archive_lookup_prefix + \ + self.msgid.strip('<>') + # patchwork metadata def is_editable(self, user): @@ -591,6 +605,15 @@ class Comment(EmailMixin, models.Model): related_query_name='comment', on_delete=models.CASCADE) + @property + def list_archive_url(self): + if not self.submission.project.list_archive_lookup_prefix: + return None + if not self.msgid: + return None + return self.project.list_archive_lookup_prefix + \ + self.msgid.strip('<>') + def get_absolute_url(self): return reverse('comment-redirect', kwargs={'comment_id': self.id})