@@ -6,5 +6,6 @@
<field type="CharField" name="listid">patchwork.ozlabs.org</field>
<field type="CharField" name="listemail">patchwork@lists.ozlabs.org</field>
<field type="CharField" name="list_archive_url">https://lists.ozlabs.org/pipermail/patchwork/</field>
+ <field type="CharField" name="list_archive_url_format">http://mid.mail-archive.com/{}</field>
</object>
</django-objects>
new file mode 100644
@@ -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_url_format',
+ field=models.CharField(blank=True, help_text=b"URL format for the list archive's Message-ID redirector. {} will be replaced by the Message-ID.", max_length=2000),
+ ),
+ ]
@@ -78,6 +78,10 @@ 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_url_format = models.CharField(
+ max_length=2000, blank=True,
+ help_text="URL format for the list archive's Message-ID redirector. "
+ "{} will be replaced by the Message-ID.")
# configuration options
@@ -358,6 +362,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_url_format:
+ return None
+ if not self.msgid:
+ return None
+ return self.project.list_archive_url_format.format(
+ self.msgid.strip('<>'))
+
# patchwork metadata
def is_editable(self, user):
@@ -591,6 +604,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_url_format:
+ return None
+ if not self.msgid:
+ return None
+ return self.project.list_archive_url_format.format(
+ self.msgid.strip('<>'))
+
def get_absolute_url(self):
return reverse('comment-redirect', kwargs={'comment_id': self.id})
Add a list_archive_url_format 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. Also add the new field to the default patchwork project fixture. Suggested-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> --- v1->v2: - add to default fixture (Daniel) - switch to using format string (Daniel) --- patchwork/fixtures/default_projects.xml | 1 + .../0035_project_list_archive_url_format.py | 20 +++++++++++++++++ patchwork/models.py | 22 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 patchwork/migrations/0035_project_list_archive_url_format.py