diff gpp/antispam/models.py @ 214:28988cce138b

Implement #83: a string filter facility like NukeSeSentinel. It currently isn't hooked up to anything. Will do that in #84.
author Brian Neal <bgneal@gmail.com>
date Fri, 14 May 2010 02:19:48 +0000
parents
children 8c1832b9d815
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/antispam/models.py	Fri May 14 02:19:48 2010 +0000
@@ -0,0 +1,22 @@
+"""Models for the antispam application."""
+from django.db import models
+from django.core.cache import cache
+
+from antispam import SPAM_PHRASE_KEY
+
+
+class SpamPhrase(models.Model):
+    """A SpamPhrase is a string that is checked for in user input. User input
+    containing a SpamPhrase should be blocked and flagged.
+    """
+    phrase = models.CharField(max_length=64)
+
+    class Meta:
+        ordering = ('phrase', )
+
+    def __unicode__(self):
+        return self.phrase
+
+    def save(self, *args, **kwargs):
+        cache.delete(SPAM_PHRASE_KEY)
+        super(SpamPhrase, self).save(*args, **kwargs)