Mercurial > public > sg101
comparison gpp/comments/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 | 91a01b8b5885 |
comparison
equal
deleted
inserted
replaced
127:2d299909e074 | 128:48621ba5c385 |
---|---|
6 from django.contrib.contenttypes.models import ContentType | 6 from django.contrib.contenttypes.models import ContentType |
7 from django.contrib.contenttypes import generic | 7 from django.contrib.contenttypes import generic |
8 from django.contrib.auth.models import User | 8 from django.contrib.auth.models import User |
9 from django.core import urlresolvers | 9 from django.core import urlresolvers |
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 COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000) | 14 COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000) |
16 | 15 |
17 class CommentManager(models.Manager): | 16 class CommentManager(models.Manager): |
51 | 50 |
52 def __unicode__(self): | 51 def __unicode__(self): |
53 return u'%s: %s...' % (self.user.username, self.comment[:50]) | 52 return u'%s: %s...' % (self.user.username, self.comment[:50]) |
54 | 53 |
55 def save(self, force_insert=False, force_update=False): | 54 def save(self, force_insert=False, force_update=False): |
56 self.html = smilify(markdown(self.comment)) | 55 self.html = site_markup(self.comment) |
57 super(Comment, self).save(force_insert, force_update) | 56 super(Comment, self).save(force_insert, force_update) |
58 | 57 |
59 def get_absolute_url(self): | 58 def get_absolute_url(self): |
60 return self.get_content_object_url() + ('#c%s' % self.id) | 59 return self.get_content_object_url() + ('#c%s' % self.id) |
61 | 60 |