Andrew Donnellan <a...@linux.ibm.com> writes: > 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 <ti...@suse.de> > Signed-off-by: Andrew Donnellan <a...@linux.ibm.com> > --- > ...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), > + ),
Would it be better to do this with str.format(), as with mpe's commit_url_format patch? Regards, Daniel > + ] > 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}) > > -- > 2.20.1 > > _______________________________________________ > Patchwork mailing list > Patchwork@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/patchwork _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork