- Author:
- iElectric
- Posted:
- October 20, 2012
- Language:
- Python
- Version:
- Not specified
- Score:
- 3 (after 3 ratings)
..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from akismet import Akismet
from django.core.management.base import BaseCommand
from django.conf import settings
from django.contrib.sites.models import Site
from django.contrib.comments.models import Comment
class Command(BaseCommand):
args = "<date> in format dd.mm.yyyy"
help = "Sends daily email repot about intranet changes"
def handle(self, *args, **options):
akismet = Akismet(key=settings.SPAMINSPECTOR_AKISMET_KEY,
blog_url="http://%s/" % Site.objects.get(pk=settings.SITE_ID).domain)
if not akismet.verify_key():
raise ValueError('no key set')
for comment in Comment.objects.all():
data = {
'user_ip': comment.ip_address,
'user_agent': '',
'referrer': '',
'comment_type': 'comment',
'comment_author': comment.user_name.encode('utf-8'),
'comment_email': comment.user_email.encode('utf-8'),
'comment_url': comment.user_url.encode('utf-8'),
}
if akismet.comment_check(comment.comment.encode('utf-8'), data, build_data=True):
comment.delete()
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 10 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
Neat idea! :-)
#
Please login first before commenting.