Author: jacob
Date: 2007-10-10 17:50:46 -0500 (Wed, 10 Oct 2007)
New Revision: 6472

Modified:
   djangoproject.com/django_website/apps/blog/models.py
   djangoproject.com/django_website/settings.py
   djangoproject.com/django_website/templates/blog/entry_archive.html
   djangoproject.com/django_website/templates/blog/entry_detail.html
   djangoproject.com/django_website/templates/flatfiles/homepage.html
   djangoproject.com/django_website/urls.py
Log:
[django-website] Added spam protection via James Bennet's nifty comment_utils 
app.

Modified: djangoproject.com/django_website/apps/blog/models.py
===================================================================
--- djangoproject.com/django_website/apps/blog/models.py        2007-10-10 
15:51:38 UTC (rev 6471)
+++ djangoproject.com/django_website/apps/blog/models.py        2007-10-10 
22:50:46 UTC (rev 6472)
@@ -1,4 +1,6 @@
+import datetime
 from django.db import models
+from comment_utils.moderation import CommentModerator, moderator
 
 class Entry(models.Model):
     pub_date = models.DateTimeField()
@@ -22,3 +24,14 @@
 
     def get_absolute_url(self):
         return "/weblog/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), 
self.slug)
+        
+    @property
+    def comments_enabled(self):
+        delta = datetime.datetime.now() - self.pub_date
+        return delta.days < 60
+
+class EntryModerator(CommentModerator):
+    akismet = True
+    enable_field = "comments_enabled"
+
+moderator.register(Entry, EntryModerator)

Modified: djangoproject.com/django_website/settings.py
===================================================================
--- djangoproject.com/django_website/settings.py        2007-10-10 15:51:38 UTC 
(rev 6471)
+++ djangoproject.com/django_website/settings.py        2007-10-10 22:50:46 UTC 
(rev 6472)
@@ -47,6 +47,7 @@
     'django_website.apps.docs',
     'django_website.apps.aggregator',
     'registration',
+    'comment_utils',
 )
 ADMIN_MEDIA_PREFIX = 'http://media.djangoproject.com/admin/'
 MEDIA_ROOT = "/home/html/djangoproject.com/m/"
@@ -74,4 +75,7 @@
 USE_I18N = False
 
 # django-registration settings
-ACCOUNT_ACTIVATION_DAYS = 3
\ No newline at end of file
+ACCOUNT_ACTIVATION_DAYS = 3
+
+# comment_utils settings
+AKISMET_API_KEY = "c892e4962244"
\ No newline at end of file

Modified: djangoproject.com/django_website/templates/blog/entry_archive.html
===================================================================
--- djangoproject.com/django_website/templates/blog/entry_archive.html  
2007-10-10 15:51:38 UTC (rev 6471)
+++ djangoproject.com/django_website/templates/blog/entry_archive.html  
2007-10-10 22:50:46 UTC (rev 6472)
@@ -2,12 +2,12 @@
 
 {% block content %}
 
-{% load comments.comments %}
+{% load comments comment_utils %}
 
 <h1>Latest entries</h1>
 
 {% for object in latest %}
-    {% get_free_comment_count for blog.entry object.id as comment_count %}
+    {% get_public_free_comment_count for blog.entry object.id as comment_count 
%}
     <h2><a href="{{ object.get_absolute_url }}">{{ object.headline }}</a></h2>
     {{ object.body }}
     <p class="date small">Posted by <strong>{{ object.author }}</strong> on {{ 
object.pub_date|date:"F j, Y" }} | <a href="{{ object.get_absolute_url 
}}#comments">{{ comment_count }} comment{{ comment_count|pluralize }}</a></p>

Modified: djangoproject.com/django_website/templates/blog/entry_detail.html
===================================================================
--- djangoproject.com/django_website/templates/blog/entry_detail.html   
2007-10-10 15:51:38 UTC (rev 6471)
+++ djangoproject.com/django_website/templates/blog/entry_detail.html   
2007-10-10 22:50:46 UTC (rev 6472)
@@ -8,8 +8,8 @@
 {{ object.body }}
 <p class="date small">Posted by <strong>{{ object.author }}</strong> on {{ 
object.pub_date|date:"F j, Y" }}</p>
 
-{% load comments %}
-{% get_free_comment_list for blog.entry object.id as comment_list %}
+{% load comments comment_utils %}
+{% get_public_free_comment_list for blog.entry object.id as comment_list %}
 
 <div id="content-secondary">
 <h2 id="comments">Comments</h2>
@@ -21,8 +21,12 @@
 </div>
 {% endfor %}
 
-<h2>Post a comment</h2>
+<h2>Comments are closed</h2>
 
+{% if object.comments_enabled %}
 {% free_comment_form for blog.entry object.id %}
+{% else %}
+<p>To prevent spam, comments are no longer allowed after sixty days.</p>
+{% endif %}
 </div>
 {% endblock %}

Modified: djangoproject.com/django_website/templates/flatfiles/homepage.html
===================================================================
--- djangoproject.com/django_website/templates/flatfiles/homepage.html  
2007-10-10 15:51:38 UTC (rev 6471)
+++ djangoproject.com/django_website/templates/flatfiles/homepage.html  
2007-10-10 22:50:46 UTC (rev 6472)
@@ -70,12 +70,11 @@
 {% block content-extra %}
 <h2>Weblog</h2>
 
-{% load comments %}
-{% load latestblogentry %}
+{% load comments comment_utils latestblogentry %}
 {% get_latest_blog_entries 4 as latest_entries %}
 
 {% for latest_entry in latest_entries %}
-    {% get_free_comment_count for blog.entry latest_entry.id as comment_count 
%}
+    {% get_public_free_comment_count for blog.entry latest_entry.id as 
comment_count %}
     <h3><a href="{{ latest_entry.get_absolute_url }}">{{ latest_entry.headline 
}}</a></h3>
     <p class="date">by <strong>{{ latest_entry.author }}</strong> on {{ 
latest_entry.pub_date|date:"M. j, Y" }}</p>
     {{ latest_entry.summary }}

Modified: djangoproject.com/django_website/urls.py
===================================================================
--- djangoproject.com/django_website/urls.py    2007-10-10 15:51:38 UTC (rev 
6471)
+++ djangoproject.com/django_website/urls.py    2007-10-10 22:50:46 UTC (rev 
6472)
@@ -9,7 +9,7 @@
 from django.views.decorators.cache import cache_page
 
 comments_info_dict = {
-    'queryset': FreeComment.objects.all(),
+    'queryset': FreeComment.objects.filter(is_public=True),
     'paginate_by': 15,
 }
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to