from django.db import models from django.contrib.comments.models import Comment class MyComment(Comment): class Meta: proxy = True verbose_name = "Comment" class BannedIP(models.Model): ip_address = models.GenericIPAddressField(unpack_ipv4=True, unique=True) def __unicode__(self): return u"%s" % self.ip_address class Meta: ordering = ('ip_address',) verbose_name = 'banned IP' verbose_name_plural = 'banned IPs' class BannedUserName(models.Model): user_name = models.CharField("user's name", max_length=50, unique=True) def __unicode__(self): return u"%s" % self.user_name class Meta: ordering = ('user_name',) # connect our signals from django.contrib.comments.signals import (comment_was_posted, comment_will_be_posted) from django.db.models.signals import pre_save from mycomments.signals import (send_comment_by_mail, check_spam_comment, set_comment_ip_address) comment_was_posted.connect(send_comment_by_mail, dispatch_uid='mycomments.models') comment_will_be_posted.connect(check_spam_comment, dispatch_uid='mycomments.models') # Note: why I have to connect to 'Comment' and not 'MyComment' is beyond me and # probably a bug, but this does the job. pre_save.connect(set_comment_ip_address, sender=Comment, dispatch_uid='mycomments.models') # vim: set ts=4 sw=4 et: