[PATCH 10/19] models: Remove 'permalink' decorator

Stephen Finucane stephen at that.guru
Thu May 11 05:45:19 AEST 2017


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 at that.guru>
---
 patchwork/models.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/patchwork/models.py b/patchwork/models.py
index bb8398b..c7e6124 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
 
@@ -528,13 +529,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
@@ -742,17 +741,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.9.3



More information about the Patchwork mailing list