Django

Code

Show
Ignore:
Timestamp:
09/19/08 15:49:50 (2 months ago)
Author:
jacob
Message:

[djangoproject.com] updated website to use Django 1.0.

Files:

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/
  • djangoproject.com/django_website/apps/blog/models.py

    r6472 r9073  
     1import akismet 
    12import datetime 
     3from django.conf import settings 
    24from django.db import models 
    3 from comment_utils.moderation import CommentModerator, moderator 
     5from django.contrib.sites.models import Site 
     6from django.contrib.comments.signals import comment_was_posted 
     7from django.utils.encoding import smart_str 
    48 
    59class Entry(models.Model): 
    610    pub_date = models.DateTimeField() 
    711    slug = models.SlugField(unique_for_date='pub_date') 
    8     headline = models.CharField(maxlength=200) 
     12    headline = models.CharField(max_length=200) 
    913    summary = models.TextField(help_text="Use raw HTML.") 
    1014    body = models.TextField(help_text="Use raw HTML.") 
    11     author = models.CharField(maxlength=100) 
     15    author = models.CharField(max_length=100) 
    1216 
    1317    class Meta: 
     
    1620        ordering = ('-pub_date',) 
    1721        get_latest_by = 'pub_date' 
    18  
    19     class Admin: 
    20         list_display = ('pub_date', 'headline', 'author') 
    2122 
    2223    def __unicode__(self): 
     
    3132        return delta.days < 60 
    3233 
    33 class EntryModerator(CommentModerator): 
    34     akismet = True 
    35     enable_field = "comments_enabled" 
    36  
    37 moderator.register(Entry, EntryModerator) 
     34def 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     
     50comment_was_posted.connect(moderate_comment)