comparison gpp/bio/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 7ea842744a57
comparison
equal deleted inserted replaced
127:2d299909e074 128:48621ba5c385
8 from django.db import models 8 from django.db import models
9 from django.contrib import auth 9 from django.contrib import auth
10 from django.conf import settings 10 from django.conf import settings
11 from django.core.cache import cache 11 from django.core.cache import cache
12 12
13 from core.markup import Markdown 13 from core.markup import SiteMarkup
14 from smiley import Smilify
15 14
16 15
17 def avatar_file_path_for_user(username, filename): 16 def avatar_file_path_for_user(username, filename):
18 return os.path.join(settings.AVATAR_DIR, 'users', username, filename) 17 return os.path.join(settings.AVATAR_DIR, 'users', username, filename)
19 18
46 45
47 class Meta: 46 class Meta:
48 ordering = ('user__username', ) 47 ordering = ('user__username', )
49 48
50 def save(self, *args, **kwargs): 49 def save(self, *args, **kwargs):
51 md = Markdown() 50 sm = SiteMarkup()
52 sm = Smilify() 51 self.profile_html = sm.convert(self.profile_text)
53 self.profile_html = sm.convert(md.convert(self.profile_text)) 52 self.signature_html = sm.convert(self.signature)
54 self.signature_html = sm.convert(md.convert(self.signature))
55 super(UserProfile, self).save(*args, **kwargs) 53 super(UserProfile, self).save(*args, **kwargs)
56 cache.delete('avatar_' + self.user.username) 54 cache.delete('avatar_' + self.user.username)