Django

Code

Changeset 6472

Show
Ignore:
Timestamp:
10/10/07 17:50:46 (1 year ago)
Author:
jacob
Message:

[django-website] Added spam protection via James Bennet's nifty comment_utils app.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • djangoproject.com/django_website/apps/blog/models.py

    r6063 r6472  
     1import datetime 
    12from django.db import models 
     3from comment_utils.moderation import CommentModerator, moderator 
    24 
    35class Entry(models.Model): 
     
    2325    def get_absolute_url(self): 
    2426        return "/weblog/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug) 
     27         
     28    @property 
     29    def comments_enabled(self): 
     30        delta = datetime.datetime.now() - self.pub_date 
     31        return delta.days < 60 
     32 
     33class EntryModerator(CommentModerator): 
     34    akismet = True 
     35    enable_field = "comments_enabled" 
     36 
     37moderator.register(Entry, EntryModerator) 
  • djangoproject.com/django_website/settings.py

    r6064 r6472  
    4848    'django_website.apps.aggregator', 
    4949    'registration', 
     50    'comment_utils', 
    5051) 
    5152ADMIN_MEDIA_PREFIX = 'http://media.djangoproject.com/admin/' 
     
    7677# django-registration settings 
    7778ACCOUNT_ACTIVATION_DAYS = 3 
     79 
     80# comment_utils settings 
     81AKISMET_API_KEY = "c892e4962244" 
  • djangoproject.com/django_website/templates/blog/entry_archive.html

    r3008 r6472  
    33{% block content %} 
    44 
    5 {% load comments.comments %} 
     5{% load comments comment_utils %} 
    66 
    77<h1>Latest entries</h1> 
    88 
    99{% for object in latest %} 
    10     {% get_free_comment_count for blog.entry object.id as comment_count %} 
     10    {% get_public_free_comment_count for blog.entry object.id as comment_count %} 
    1111    <h2><a href="{{ object.get_absolute_url }}">{{ object.headline }}</a></h2> 
    1212    {{ object.body }} 
  • djangoproject.com/django_website/templates/blog/entry_detail.html

    r4401 r6472  
    99<p class="date small">Posted by <strong>{{ object.author }}</strong> on {{ object.pub_date|date:"F j, Y" }}</p> 
    1010 
    11 {% load comments %} 
    12 {% get_free_comment_list for blog.entry object.id as comment_list %} 
     11{% load comments comment_utils %} 
     12{% get_public_free_comment_list for blog.entry object.id as comment_list %} 
    1313 
    1414<div id="content-secondary"> 
     
    2222{% endfor %} 
    2323 
    24 <h2>Post a comment</h2> 
     24<h2>Comments are closed</h2> 
    2525 
     26{% if object.comments_enabled %} 
    2627{% free_comment_form for blog.entry object.id %} 
     28{% else %} 
     29<p>To prevent spam, comments are no longer allowed after sixty days.</p> 
     30{% endif %} 
    2731</div> 
    2832{% endblock %} 
  • djangoproject.com/django_website/templates/flatfiles/homepage.html

    r6060 r6472  
    7171<h2>Weblog</h2> 
    7272 
    73 {% load comments %} 
    74 {% load latestblogentry %} 
     73{% load comments comment_utils latestblogentry %} 
    7574{% get_latest_blog_entries 4 as latest_entries %} 
    7675 
    7776{% for latest_entry in latest_entries %} 
    78     {% get_free_comment_count for blog.entry latest_entry.id as comment_count %} 
     77    {% get_public_free_comment_count for blog.entry latest_entry.id as comment_count %} 
    7978    <h3><a href="{{ latest_entry.get_absolute_url }}">{{ latest_entry.headline }}</a></h3> 
    8079    <p class="date">by <strong>{{ latest_entry.author }}</strong> on {{ latest_entry.pub_date|date:"M. j, Y" }}</p> 
  • djangoproject.com/django_website/urls.py

    r6064 r6472  
    1010 
    1111comments_info_dict = { 
    12     'queryset': FreeComment.objects.all(), 
     12    'queryset': FreeComment.objects.filter(is_public=True), 
    1313    'paginate_by': 15, 
    1414}