Mercurial > public > sg101
diff gpp/comments/models.py @ 124:9c18250972d5
Refactored the markdown/smiley logic. Created classes for Markdown and Smilify. No longer call render_to_string() in models.py for various models.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 14 Nov 2009 04:32:32 +0000 |
parents | d0d779dd0832 |
children | 48621ba5c385 |
line wrap: on
line diff
--- a/gpp/comments/models.py Sun Nov 08 21:15:31 2009 +0000 +++ b/gpp/comments/models.py Sat Nov 14 04:32:32 2009 +0000 @@ -6,9 +6,11 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic from django.contrib.auth.models import User -from django.template.loader import render_to_string from django.core import urlresolvers +from core.markup import markdown +from smiley import smilify + COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000) @@ -51,8 +53,7 @@ return u'%s: %s...' % (self.user.username, self.comment[:50]) def save(self, force_insert=False, force_update=False): - html = render_to_string('comments/markdown.html', {'data': self.comment}) - self.html = html.strip() + self.html = smilify(markdown(self.comment)) super(Comment, self).save(force_insert, force_update) def get_absolute_url(self):