Mercurial > public > sg101
annotate antispam/models.py @ 917:0365fdbb4d78
Fix app conflict with messages.
Django's messages app label conflicts with our messages app.
We can't easily rename our label as that will make us rename database tables.
Since our app came first we'll just customize Django messages label.
For Django 1.7.7 upgrade.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 06 Apr 2015 20:02:25 -0500 |
parents | ee87ea74d46b |
children |
rev | line source |
---|---|
bgneal@214 | 1 """Models for the antispam application.""" |
bgneal@214 | 2 from django.db import models |
bgneal@214 | 3 from django.core.cache import cache |
bgneal@214 | 4 |
bgneal@214 | 5 from antispam import SPAM_PHRASE_KEY |
bgneal@214 | 6 |
bgneal@214 | 7 |
bgneal@214 | 8 class SpamPhrase(models.Model): |
bgneal@214 | 9 """A SpamPhrase is a string that is checked for in user input. User input |
bgneal@214 | 10 containing a SpamPhrase should be blocked and flagged. |
bgneal@214 | 11 """ |
bgneal@214 | 12 phrase = models.CharField(max_length=64) |
bgneal@214 | 13 |
bgneal@214 | 14 class Meta: |
bgneal@214 | 15 ordering = ('phrase', ) |
bgneal@214 | 16 |
bgneal@214 | 17 def __unicode__(self): |
bgneal@214 | 18 return self.phrase |
bgneal@214 | 19 |
bgneal@214 | 20 def save(self, *args, **kwargs): |
bgneal@214 | 21 cache.delete(SPAM_PHRASE_KEY) |
bgneal@215 | 22 self.phrase = self.phrase.lower() |
bgneal@214 | 23 super(SpamPhrase, self).save(*args, **kwargs) |