Mercurial > public > sg101
comparison potd/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 | 2d35e5f97a99 |
children |
comparison
equal
deleted
inserted
replaced
1034:2f36abf65a62 | 1035:eeaf387803c6 |
---|---|
12 from StringIO import StringIO | 12 from StringIO import StringIO |
13 | 13 |
14 from django.db import models | 14 from django.db import models |
15 from django.contrib.auth.models import User | 15 from django.contrib.auth.models import User |
16 from django.core.files.base import ContentFile | 16 from django.core.files.base import ContentFile |
17 from django.core.urlresolvers import reverse | |
17 | 18 |
18 POTD_THUMB_WIDTH = 120 | 19 POTD_THUMB_WIDTH = 120 |
19 | 20 |
20 def scale_image(image): | 21 def scale_image(image): |
21 (w, h) = image.size | 22 (w, h) = image.size |
40 ordering = ('-date_added', '-caption') | 41 ordering = ('-date_added', '-caption') |
41 | 42 |
42 def __unicode__(self): | 43 def __unicode__(self): |
43 return u'%s (%s)' % (self.caption, self.pk) | 44 return u'%s (%s)' % (self.caption, self.pk) |
44 | 45 |
45 @models.permalink | |
46 def get_absolute_url(self): | 46 def get_absolute_url(self): |
47 return ('potd-archive', [str(self.id)]) | 47 return reverse('potd-archive', args=[str(self.id)]) |
48 | 48 |
49 def save(self, *args, **kwargs): | 49 def save(self, *args, **kwargs): |
50 if not self.pk: | 50 if not self.pk: |
51 self.generate_thumb() | 51 self.generate_thumb() |
52 self.date_added = datetime.datetime.now() | 52 self.date_added = datetime.datetime.now() |