Mercurial > public > sg101
comparison antispam/models.py @ 581:ee87ea74d46b
For Django 1.4, rearranged project structure for new manage.py.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 May 2012 17:10:48 -0500 |
parents | gpp/antispam/models.py@8c1832b9d815 |
children |
comparison
equal
deleted
inserted
replaced
580:c525f3e0b5d0 | 581:ee87ea74d46b |
---|---|
1 """Models for the antispam application.""" | |
2 from django.db import models | |
3 from django.core.cache import cache | |
4 | |
5 from antispam import SPAM_PHRASE_KEY | |
6 | |
7 | |
8 class SpamPhrase(models.Model): | |
9 """A SpamPhrase is a string that is checked for in user input. User input | |
10 containing a SpamPhrase should be blocked and flagged. | |
11 """ | |
12 phrase = models.CharField(max_length=64) | |
13 | |
14 class Meta: | |
15 ordering = ('phrase', ) | |
16 | |
17 def __unicode__(self): | |
18 return self.phrase | |
19 | |
20 def save(self, *args, **kwargs): | |
21 cache.delete(SPAM_PHRASE_KEY) | |
22 self.phrase = self.phrase.lower() | |
23 super(SpamPhrase, self).save(*args, **kwargs) |