Mercurial > public > sg101
comparison shoutbox/models.py @ 1035:eeaf387803c6
Remove usages of @models.permalink.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 26 Dec 2015 21:33:55 -0600 |
parents | 98d2388b6bb2 |
children |
comparison
equal
deleted
inserted
replaced
1034:2f36abf65a62 | 1035:eeaf387803c6 |
---|---|
3 """ | 3 """ |
4 import datetime | 4 import datetime |
5 | 5 |
6 from django.db import models | 6 from django.db import models |
7 from django.contrib.auth.models import User | 7 from django.contrib.auth.models import User |
8 from django.core.urlresolvers import reverse | |
8 from django.utils.html import escape, urlize | 9 from django.utils.html import escape, urlize |
9 | 10 |
10 from smiley.utils import smilify_html | 11 from smiley.utils import smilify_html |
11 | 12 |
12 | 13 |
22 def __unicode__(self): | 23 def __unicode__(self): |
23 if len(self.shout) > 60: | 24 if len(self.shout) > 60: |
24 return self.shout[:60] + "..." | 25 return self.shout[:60] + "..." |
25 return self.shout | 26 return self.shout |
26 | 27 |
27 @models.permalink | |
28 def get_absolute_url(self): | 28 def get_absolute_url(self): |
29 return ('shoutbox-view', [str(self.id)]) | 29 return reverse('shoutbox-view', args=[str(self.pk)]) |
30 | 30 |
31 def save(self, *args, **kwargs): | 31 def save(self, *args, **kwargs): |
32 if not self.id: | 32 if not self.id: |
33 self.shout_date = datetime.datetime.now() | 33 self.shout_date = datetime.datetime.now() |
34 self.html = urlize(smilify_html(escape(self.shout)), trim_url_limit=15, | 34 self.html = urlize(smilify_html(escape(self.shout)), trim_url_limit=15, |