Mercurial > public > sg101
comparison gpp/messages/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 | 5c889b587416 |
comparison
equal
deleted
inserted
replaced
127:2d299909e074 | 128:48621ba5c385 |
---|---|
1 """Models for the messages application.""" | 1 """Models for the messages application.""" |
2 | 2 |
3 import datetime | 3 import datetime |
4 | |
4 from django.db import models | 5 from django.db import models |
5 from django.db.models import Q | 6 from django.db.models import Q |
6 from django.contrib.auth.models import User | 7 from django.contrib.auth.models import User |
7 from core.markup import markdown | 8 |
8 from smiley import smilify | 9 from core.markup import site_markup |
9 | 10 |
10 | 11 |
11 class MessageManager(models.Manager): | 12 class MessageManager(models.Manager): |
12 """The manager for the Message model. Provides convenience functions.""" | 13 """The manager for the Message model. Provides convenience functions.""" |
13 | 14 |
61 return False | 62 return False |
62 | 63 |
63 def save(self, force_insert = False, force_update = False): | 64 def save(self, force_insert = False, force_update = False): |
64 if not self.id: | 65 if not self.id: |
65 self.send_date = datetime.datetime.now() | 66 self.send_date = datetime.datetime.now() |
66 self.html = smilify(markdown(self.message)) | 67 self.html = site_markup(self.message) |
67 super(Message, self).save(force_insert, force_update) | 68 super(Message, self).save(force_insert, force_update) |
68 | 69 |
69 @models.permalink | 70 @models.permalink |
70 def get_absolute_url(self): | 71 def get_absolute_url(self): |
71 return ('messages.views.view', [str(self.id)]) | 72 return ('messages.views.view', [str(self.id)]) |