Changeset 9073 for djangoproject.com/django_website/apps/blog
- Timestamp:
- 09/19/08 15:49:50 (2 months ago)
- Files:
-
- djangoproject.com (modified) (1 prop)
- djangoproject.com/django_website/apps/blog/admin.py (added)
- djangoproject.com/django_website/apps/blog/models.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
djangoproject.com
- Property svn:externals changed from
django -r6063 http://code.djangoproject.com/svn/django/trunk/django/
registration -r139 http://django-registration.googlecode.com/svn/trunk/registration/
comment_utils -r78 http://django-comment-utils.googlecode.com/svn/trunk/comment_utils/
contact_form -r48 http://django-contact-form.googlecode.com/svn/trunk/contact_form/
to
django http://code.djangoproject.com/svn/django/tags/releases/1.0/django
registration -r168 http://django-registration.googlecode.com/svn/trunk/registration/
contact_form -r49 http://django-contact-form.googlecode.com/svn/trunk/contact_form/
- Property svn:externals changed from
djangoproject.com/django_website/apps/blog/models.py
r6472 r9073 1 import akismet 1 2 import datetime 3 from django.conf import settings 2 4 from django.db import models 3 from comment_utils.moderation import CommentModerator, moderator 5 from django.contrib.sites.models import Site 6 from django.contrib.comments.signals import comment_was_posted 7 from django.utils.encoding import smart_str 4 8 5 9 class Entry(models.Model): 6 10 pub_date = models.DateTimeField() 7 11 slug = models.SlugField(unique_for_date='pub_date') 8 headline = models.CharField(max length=200)12 headline = models.CharField(max_length=200) 9 13 summary = models.TextField(help_text="Use raw HTML.") 10 14 body = models.TextField(help_text="Use raw HTML.") 11 author = models.CharField(max length=100)15 author = models.CharField(max_length=100) 12 16 13 17 class Meta: … … 16 20 ordering = ('-pub_date',) 17 21 get_latest_by = 'pub_date' 18 19 class Admin:20 list_display = ('pub_date', 'headline', 'author')21 22 22 23 def __unicode__(self): … … 31 32 return delta.days < 60 32 33 33 class EntryModerator(CommentModerator): 34 akismet = True 35 enable_field = "comments_enabled" 36 37 moderator.register(Entry, EntryModerator) 34 def moderate_comment(sender, comment, request, **kwargs): 35 ak = akismet.Akismet( 36 key = settings.AKISMET_API_KEY, 37 blog_url = 'http://%s/' % Site.objects.get_current().domain 38 ) 39 data = { 40 'user_ip': request.META.get('REMOTE_ADDR', '127.0.0.1'), 41 'user_agent': request.META.get('HTTP_USER_AGENT', ''), 42 'referrer': request.META.get('HTTP_REFERRER', ''), 43 'comment_type': 'comment', 44 'comment_author': smart_str(comment.user_name), 45 } 46 if ak.comment_check(smart_str(comment.comment), data=data, build_data=True): 47 comment.is_public = False 48 comment.save() 49 50 comment_was_posted.connect(moderate_comment)
