changeset 1035:eeaf387803c6

Remove usages of @models.permalink.
author Brian Neal <bgneal@gmail.com>
date Sat, 26 Dec 2015 21:33:55 -0600
parents 2f36abf65a62
children b7b98c729abc
files bio/admin.py bio/models.py bio/urls.py contests/models.py downloads/models.py forums/models.py polls/models.py potd/models.py shoutbox/models.py weblinks/models.py ygroup/models.py
diffstat 11 files changed, 30 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/bio/admin.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/bio/admin.py	Sat Dec 26 21:33:55 2015 -0600
@@ -20,9 +20,10 @@
 
 class UserProfileAdmin(admin.ModelAdmin):
     search_fields = ['user__username', 'user__first_name', 'user__last_name',
-            'user__email']
+                     'user__email']
     exclude = ['profile_html', 'signature_html']
-    list_display = ['__unicode__', 'user_is_active', 'get_status_display', 'status_date']
+    list_display = ['__unicode__', 'user_is_active', 'get_status_display',
+                    'status_date']
     readonly_fields = ['status', 'status_date', 'update_date']
     list_filter = ['status', ]
     date_hierarchy = 'status_date'
--- a/bio/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/bio/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -9,6 +9,7 @@
 from django.contrib.auth.models import User
 from django.conf import settings
 from django.core.cache import cache
+from django.core.urlresolvers import reverse
 from django.template.loader import render_to_string
 
 from core.markup import SiteMarkup
@@ -137,9 +138,8 @@
         if content_update:
             notify_profile_content_update(self)
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('bio-view_profile', (), {'username': self.user.username})
+        return reverse('bio-view_profile', kwargs={'username': self.user.username})
 
     def badge_ownership(self):
         return BadgeOwnership.objects.filter(profile=self).select_related('badge')
--- a/bio/urls.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/bio/urls.py	Sat Dec 26 21:33:55 2015 -0600
@@ -9,7 +9,8 @@
         name='bio-member_list'),
     url(r'^members/search/$', bio.views.member_search, name='bio-member_search'),
     url(r'^me/$', bio.views.my_profile, name='bio-me'),
-    url(r'^view/(?P<username>[\w.@+-]{1,30})/$', bio.views.view_profile, name='bio-view_profile'),
+    url(r'^view/(?P<username>[\w.@+-]{1,30})/$', bio.views.view_profile,
+        name='bio-view_profile'),
     url(r'^edit/$', bio.views.edit_profile, name='bio-edit_profile'),
     url(r'^edit/elsewhere/$', bio.views.edit_elsewhere, name='bio-edit_elsewhere'),
     url(r'^avatar/$', bio.views.change_avatar, name='bio-change_avatar'),
--- a/contests/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/contests/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -5,8 +5,9 @@
 import random
 import datetime
 
+from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
 from django.db import models
-from django.contrib.auth.models import User
 
 
 class PublicContestManager(models.Manager):
@@ -51,9 +52,8 @@
     def __unicode__(self):
         return self.title
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('contests-contest', [], {'slug': self.slug})
+        return reverse('contests-contest', kwargs={'slug': self.slug})
 
     def save(self, *args, **kwargs):
         if not self.pk and not self.creation_date:
--- a/downloads/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/downloads/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -4,8 +4,9 @@
 import os
 
 import datetime
+from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
 from django.db import models
-from django.contrib.auth.models import User
 from django.template.defaultfilters import filesizeformat
 
 from core.markup import site_markup
@@ -108,9 +109,8 @@
     def __unicode__(self):
         return self.title
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('downloads-details', [str(self.id)])
+        return reverse('downloads-details', args=[str(self.pk)])
 
     def vote(self, vote_value):
         """receives a vote_value and updates internal score accordingly"""
--- a/forums/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/forums/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -7,6 +7,7 @@
 from django.db.models import Q
 from django.contrib.auth.models import User, Group
 from django.core.cache import cache
+from django.core.urlresolvers import reverse
 
 from core.markup import site_markup
 from oembed.models import Oembed
@@ -102,9 +103,8 @@
     def __unicode__(self):
         return self.name
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('forums-forum_index', [self.slug])
+        return reverse('forums-forum_index', kwargs={'slug': self.slug})
 
     def topic_count_update(self):
         """Call to notify the forum that its topic count has been updated."""
@@ -194,13 +194,11 @@
     def __unicode__(self):
         return self.name
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('forums-topic_index', [self.pk])
+        return reverse('forums-topic_index', kwargs={'id': str(self.pk)})
 
-    @models.permalink
     def get_latest_post_url(self):
-        return ('forums-topic_latest', [self.pk])
+        return reverse('forums-topic_latest', kwargs={'id': str(self.pk)})
 
     def post_count_update(self):
         """
@@ -293,9 +291,8 @@
         verbose_name = 'forum post'
         verbose_name_plural = 'forum posts'
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('forums-goto_post', [self.pk])
+        return reverse('forums-goto_post', args=[str(self.pk)])
 
     def summary(self):
         limit = 65
--- a/polls/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/polls/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -5,6 +5,7 @@
 import datetime
 
 from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
 from django.db import models
 from django.db.models import Q
 
@@ -47,9 +48,8 @@
         ordering = ('-start_date', )
         get_latest_by = 'start_date'
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('polls-detail', [], {'poll_id': str(self.id)})
+        return reverse('polls-detail', kwargs={'poll_id': str(self.pk)})
 
     def results(self):
         """
--- a/potd/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/potd/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -14,6 +14,7 @@
 from django.db import models
 from django.contrib.auth.models import User
 from django.core.files.base import ContentFile
+from django.core.urlresolvers import reverse
 
 POTD_THUMB_WIDTH = 120
 
@@ -42,9 +43,8 @@
     def __unicode__(self):
         return u'%s (%s)' % (self.caption, self.pk)
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('potd-archive', [str(self.id)])
+        return reverse('potd-archive', args=[str(self.id)])
 
     def save(self, *args, **kwargs):
         if not self.pk:
--- a/shoutbox/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/shoutbox/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -5,6 +5,7 @@
 
 from django.db import models
 from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
 from django.utils.html import escape, urlize
 
 from smiley.utils import smilify_html
@@ -24,9 +25,8 @@
             return self.shout[:60] + "..."
         return self.shout
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('shoutbox-view', [str(self.id)])
+        return reverse('shoutbox-view', args=[str(self.pk)])
 
     def save(self, *args, **kwargs):
         if not self.id:
--- a/weblinks/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/weblinks/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -3,8 +3,9 @@
 """
 import datetime
 
+from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
 from django.db import models
-from django.contrib.auth.models import User
 
 
 class Category(models.Model):
@@ -68,9 +69,8 @@
 
         super(Link, self).save(*args, **kwargs)
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('weblinks-link_detail', [str(self.id)])
+        return reverse('weblinks-link_detail', args=[str(self.pk)])
 
     def search_title(self):
         return self.title
--- a/ygroup/models.py	Sat Dec 26 15:28:16 2015 -0600
+++ b/ygroup/models.py	Sat Dec 26 21:33:55 2015 -0600
@@ -2,6 +2,7 @@
 Models for the ygroup application, which is a read-only archive of messages
 from the old Yahoo Group.
 """
+from django.core.urlresolvers import reverse
 from django.db import models
 
 
@@ -20,9 +21,8 @@
     def __unicode__(self):
         return u'Thread %d, %s' % (self.pk, self.title)
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('ygroup-thread_view', [self.id])
+        return reverse('ygroup-thread_view', args=[self.pk])
 
 
 class Post(models.Model):
@@ -44,9 +44,8 @@
     def __unicode__(self):
         return u'Post %d, %s' % (self.pk, self.title)
 
-    @models.permalink
     def get_absolute_url(self):
-        return ('ygroup-post_view', [], {'pk': self.id})
+        return reverse('ygroup-post_view', kwargs={'pk': str(self.pk)})
 
     def search_title(self):
         return self.title