Mercurial > public > sg101
comparison gpp/gcalendar/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 | dbd703f7d63a |
children | 48621ba5c385 |
comparison
equal
deleted
inserted
replaced
123:3ae999b0c53b | 124:9c18250972d5 |
---|---|
2 Models for the gcalendar application. | 2 Models for the gcalendar application. |
3 """ | 3 """ |
4 from django.db import models | 4 from django.db import models |
5 from django.db.models import Q | 5 from django.db.models import Q |
6 from django.contrib.auth.models import User | 6 from django.contrib.auth.models import User |
7 from django.template.loader import render_to_string | 7 |
8 from core.markup import markdown | |
9 from smiley import smilify | |
8 | 10 |
9 | 11 |
10 class PendingEventManager(models.Manager): | 12 class PendingEventManager(models.Manager): |
11 """A manager for pending events.""" | 13 """A manager for pending events.""" |
12 | 14 |
88 | 90 |
89 class Meta: | 91 class Meta: |
90 ordering = ('-date_submitted', ) | 92 ordering = ('-date_submitted', ) |
91 | 93 |
92 def save(self, *args, **kwargs): | 94 def save(self, *args, **kwargs): |
93 html = render_to_string('gcalendar/markdown.html', {'data': self.description}) | 95 self.html = smilify(markdown(self.description)) |
94 self.html = html.strip() | |
95 super(Event, self).save(*args, **kwargs) | 96 super(Event, self).save(*args, **kwargs) |
96 | 97 |
97 def needs_approval(self): | 98 def needs_approval(self): |
98 return self.status in (self.NEW, self.EDIT_REQ, self.DEL_REQ) | 99 return self.status in (self.NEW, self.EDIT_REQ, self.DEL_REQ) |
99 | 100 |
100 | |
101 # vim: ts=4 sw=4 |