diff gpp/forums/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 19b64e8f02a2
children 48621ba5c385
line wrap: on
line diff
--- a/gpp/forums/models.py	Sun Nov 08 21:15:31 2009 +0000
+++ b/gpp/forums/models.py	Sat Nov 14 04:32:32 2009 +0000
@@ -6,7 +6,8 @@
 from django.db import models
 from django.db.models import Q
 from django.contrib.auth.models import User, Group
-from django.template.loader import render_to_string
+from core.markup import markdown
+from smiley import smilify
 
 
 POST_EDIT_DELTA = datetime.timedelta(seconds=3)
@@ -251,8 +252,7 @@
         return self.summary()
 
     def save(self, *args, **kwargs):
-        html = render_to_string('forums/post.html', {'data': self.body})
-        self.html = html.strip()
+        self.html = smilify(markdown(self.body))
         super(Post, self).save(*args, **kwargs)
 
     def delete(self, *args, **kwargs):