Message ID | 20171102102844.18931-2-stephen@that.guru |
---|---|
State | Accepted |
Headers | show |
Series | Add support for Django 1.11 | expand |
Hi Stephen, I've been working on this too - I had queued up your patches locally and done some work. I think you're missing the following two hunks, apart from that it looks good and passes all my tests. diff --git a/patchwork/models.py b/patchwork/models.py index 3bf770d6c5f2..7d413d933614 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -383,9 +383,8 @@ class SeriesMixin(object): class CoverLetter(SeriesMixin, Submission): - @models.permalink def get_mbox_url(self): - return ('cover-mbox', (), {'cover_id': self.id}) + return reverse('cover-mbox', kwargs={'cover_id': self.id}) @python_2_unicode_compatible @@ -697,9 +696,8 @@ class Series(FilenameMixin, models.Model): patch=patch, number=number) - @models.permalink def get_mbox_url(self): - return ('series-mbox', (), {'series_id': self.id}) + return reverse('series-mbox', kwargs={'series_id': self.id}) def __str__(self): return self.name if self.name else 'Untitled series #%d' % self.id Regards, Daniel > This is deprecated in Django 1.11 [1] Let's pre-empt the inevitable > warnings...or not [2]. > > [1] https://docs.djangoproject.com/en/dev/releases/1.11/#features-deprecated-in-1-11 > [2] https://docs.djangoproject.com/en/dev/releases/1.11/#deprecating-warnings-are-no-longer-loud-by-default > > Signed-off-by: Stephen Finucane <stephen@that.guru> > --- > patchwork/models.py | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) > > diff --git a/patchwork/models.py b/patchwork/models.py > index d4075cf3..3bf770d6 100644 > --- a/patchwork/models.py > +++ b/patchwork/models.py > @@ -34,6 +34,7 @@ from django.utils.encoding import python_2_unicode_compatible > from django.utils.functional import cached_property > > from patchwork.compat import is_authenticated > +from patchwork.compat import reverse > from patchwork.fields import HashField > from patchwork.hasher import hash_diff > > @@ -548,13 +549,11 @@ class Patch(SeriesMixin, Submission): > > return counts > > - @models.permalink > def get_absolute_url(self): > - return ('patch-detail', (), {'patch_id': self.id}) > + return reverse('patch-detail', kwargs={'patch_id': self.id}) > > - @models.permalink > def get_mbox_url(self): > - return ('patch-mbox', (), {'patch_id': self.id}) > + return reverse('patch-mbox', kwargs={'patch_id': self.id}) > > def __str__(self): > return self.name > @@ -776,17 +775,17 @@ class Bundle(models.Model): > return BundlePatch.objects.create(bundle=self, patch=patch, > order=max_order + 1) > > - @models.permalink > def get_absolute_url(self): > - return ('bundle-detail', (), { > + return reverse('bundle-detail', kwargs={ > 'username': self.owner.username, > 'bundlename': self.name, > }) > > - @models.permalink > def get_mbox_url(self): > - return ('bundle-mbox', (), {'bundlename': self.name, > - 'username': self.owner.username}) > + return reverse('bundle-mbox', kwargs={ > + 'bundlename': self.name, > + 'username': self.owner.username > + }) > > class Meta: > unique_together = [('owner', 'name')] > -- > 2.13.6 > > _______________________________________________ > Patchwork mailing list > Patchwork@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/patchwork
diff --git a/patchwork/models.py b/patchwork/models.py index d4075cf3..3bf770d6 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -34,6 +34,7 @@ from django.utils.encoding import python_2_unicode_compatible from django.utils.functional import cached_property from patchwork.compat import is_authenticated +from patchwork.compat import reverse from patchwork.fields import HashField from patchwork.hasher import hash_diff @@ -548,13 +549,11 @@ class Patch(SeriesMixin, Submission): return counts - @models.permalink def get_absolute_url(self): - return ('patch-detail', (), {'patch_id': self.id}) + return reverse('patch-detail', kwargs={'patch_id': self.id}) - @models.permalink def get_mbox_url(self): - return ('patch-mbox', (), {'patch_id': self.id}) + return reverse('patch-mbox', kwargs={'patch_id': self.id}) def __str__(self): return self.name @@ -776,17 +775,17 @@ class Bundle(models.Model): return BundlePatch.objects.create(bundle=self, patch=patch, order=max_order + 1) - @models.permalink def get_absolute_url(self): - return ('bundle-detail', (), { + return reverse('bundle-detail', kwargs={ 'username': self.owner.username, 'bundlename': self.name, }) - @models.permalink def get_mbox_url(self): - return ('bundle-mbox', (), {'bundlename': self.name, - 'username': self.owner.username}) + return reverse('bundle-mbox', kwargs={ + 'bundlename': self.name, + 'username': self.owner.username + }) class Meta: unique_together = [('owner', 'name')]
This is deprecated in Django 1.11 [1] Let's pre-empt the inevitable warnings...or not [2]. [1] https://docs.djangoproject.com/en/dev/releases/1.11/#features-deprecated-in-1-11 [2] https://docs.djangoproject.com/en/dev/releases/1.11/#deprecating-warnings-are-no-longer-loud-by-default Signed-off-by: Stephen Finucane <stephen@that.guru> --- patchwork/models.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)