Mercurial > public > sg101
comparison downloads/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 | 5ba2508939f7 |
children | f0ac48aa8c64 |
comparison
equal
deleted
inserted
replaced
1034:2f36abf65a62 | 1035:eeaf387803c6 |
---|---|
2 Models for the downloads application. | 2 Models for the downloads application. |
3 """ | 3 """ |
4 import os | 4 import os |
5 | 5 |
6 import datetime | 6 import datetime |
7 from django.contrib.auth.models import User | |
8 from django.core.urlresolvers import reverse | |
7 from django.db import models | 9 from django.db import models |
8 from django.contrib.auth.models import User | |
9 from django.template.defaultfilters import filesizeformat | 10 from django.template.defaultfilters import filesizeformat |
10 | 11 |
11 from core.markup import site_markup | 12 from core.markup import site_markup |
12 | 13 |
13 | 14 |
106 public_objects = PublicDownloadManager() | 107 public_objects = PublicDownloadManager() |
107 | 108 |
108 def __unicode__(self): | 109 def __unicode__(self): |
109 return self.title | 110 return self.title |
110 | 111 |
111 @models.permalink | |
112 def get_absolute_url(self): | 112 def get_absolute_url(self): |
113 return ('downloads-details', [str(self.id)]) | 113 return reverse('downloads-details', args=[str(self.pk)]) |
114 | 114 |
115 def vote(self, vote_value): | 115 def vote(self, vote_value): |
116 """receives a vote_value and updates internal score accordingly""" | 116 """receives a vote_value and updates internal score accordingly""" |
117 total_score = self.average_score * self.total_votes | 117 total_score = self.average_score * self.total_votes |
118 total_score += vote_value | 118 total_score += vote_value |