comparison gpp/downloads/models.py @ 128:48621ba5c385

Fixing #36, Smilify doesn't work when a smiley appears first before other text. Refactored the smiley system to produce markdown as well as HTML.
author Brian Neal <bgneal@gmail.com>
date Fri, 20 Nov 2009 01:43:32 +0000
parents 9c18250972d5
children 5c889b587416
comparison
equal deleted inserted replaced
127:2d299909e074 128:48621ba5c385
6 import datetime 6 import datetime
7 from django.db import models 7 from django.db import models
8 from django.contrib.auth.models import User 8 from django.contrib.auth.models import User
9 from django.template.defaultfilters import filesizeformat 9 from django.template.defaultfilters import filesizeformat
10 10
11 from core.markup import markdown 11 from core.markup import site_markup
12 from smiley import smilify
13 12
14 13
15 class Category(models.Model): 14 class Category(models.Model):
16 """Downloads belong to categories.""" 15 """Downloads belong to categories."""
17 title = models.CharField(max_length=64) 16 title = models.CharField(max_length=64)
72 @models.permalink 71 @models.permalink
73 def get_absolute_url(self): 72 def get_absolute_url(self):
74 return ('downloads-details', [str(self.id)]) 73 return ('downloads-details', [str(self.id)])
75 74
76 def save(self, force_insert=False, force_update=False): 75 def save(self, force_insert=False, force_update=False):
77 self.html = smilify(markdown(self.description)) 76 self.html = site_markup(self.description)
78 super(Download, self).save(force_insert, force_update) 77 super(Download, self).save(force_insert, force_update)
79 78
80 def vote(self, vote_value): 79 def vote(self, vote_value):
81 """receives a vote_value and updates internal score accordingly""" 80 """receives a vote_value and updates internal score accordingly"""
82 total_score = self.average_score * self.total_votes 81 total_score = self.average_score * self.total_votes