Mercurial > public > sg101
diff gpp/bio/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 | f8f4514b806a |
children | 48621ba5c385 |
line wrap: on
line diff
--- a/gpp/bio/models.py Sun Nov 08 21:15:31 2009 +0000 +++ b/gpp/bio/models.py Sat Nov 14 04:32:32 2009 +0000 @@ -8,9 +8,11 @@ from django.db import models from django.contrib import auth from django.conf import settings -from django.template.loader import render_to_string from django.core.cache import cache +from core.markup import Markdown +from smiley import Smilify + def avatar_file_path_for_user(username, filename): return os.path.join(settings.AVATAR_DIR, 'users', username, filename) @@ -46,10 +48,9 @@ ordering = ('user__username', ) def save(self, *args, **kwargs): - html = render_to_string('bio/markdown.html', {'data': self.profile_text}) - self.profile_html = html.strip() - html = render_to_string('bio/markdown.html', {'data': self.signature}) - self.signature_html = html.strip() + md = Markdown() + sm = Smilify() + self.profile_html = sm.convert(md.convert(self.profile_text)) + self.signature_html = sm.convert(md.convert(self.signature)) super(UserProfile, self).save(*args, **kwargs) cache.delete('avatar_' + self.user.username) -