예제 #1
0
 def connect(self):
     comment_will_be_posted.connect(self.pre_save_moderation,
                                    sender=TmpXtdComment)
     confirmation_received.connect(self.post_save_moderation,
                                   sender=TmpXtdComment)
     comment_was_flagged.connect(self.comment_flagged,
                                 sender=get_model())
예제 #2
0
 def connect(self):
     comment_will_be_posted.connect(self.pre_save_moderation,
                                    sender=TmpXtdComment)
     confirmation_received.connect(self.post_save_moderation,
                                   sender=TmpXtdComment)
     comment_was_flagged.connect(self.comment_flagged,
                                 sender=get_model())
예제 #3
0
    def ready(self):
        from froide.account import (account_canceled, account_merged,
                                    account_made_private)
        from froide.account.export import registry
        from froide.helper.search import search_registry
        from django_comments.signals import comment_will_be_posted
        from froide.foirequest import signals  # noqa
        from .utils import (cancel_user, merge_user, export_user_data,
                            make_account_private)

        account_canceled.connect(cancel_user)
        account_merged.connect(merge_user)
        account_made_private.connect(make_account_private)
        registry.register(export_user_data)
        search_registry.register(add_search)
        comment_will_be_posted.connect(signals.pre_comment_foimessage)
예제 #4
0
from django.db import models
from django_comments.models import Comment
from django_comments.managers import CommentManager
from django_comments.signals import comment_will_be_posted


class RatingComment(Comment):
    objects = CommentManager()

    rating = models.IntegerField(blank=True, default=-1)


def make_sure_user_was_authenticated(sender, comment, request, **kwargs):
    return request.user.is_authenticated


comment_will_be_posted.connect(make_sure_user_was_authenticated)
예제 #5
0
        'earn money online',
        'adult-friend-finder',
        'Hi, interesting post. I have been pondering this issue,so thanks for sharing. I will definitely be subscribing to your blog.',
        'Hello. And Bye.',
        'http://quick-ways-to-earn-extra-cash.blogspot.com/'
        'earn money online',
        'http://www.mydatelove.com',
        'best buy and loss weight',
    ]

    comment = kwargs['comment'].comment
    request = kwargs['request']

    if not request.user.is_authenticated():
        return False

    if not comment or comment in blacklist_identical:
        return False

    for b in blacklist_contains:
        if comment.find(b) != -1:
            return False

    if strip_tags(comment) != comment:
        return False

    return True


comment_will_be_posted.connect(comment_spam_test)
예제 #6
0
from akismet import Akismet
from django.conf import settings
from django_comments.models import Comment
from django_comments.signals import comment_will_be_posted
from django.contrib.sites.models import Site
from django.utils.encoding import smart_str
from django.utils import timezone


def moderate_comment(sender, comment, request, **kwargs):
    if not comment.id:
        entry = comment.content_object
        delta = timezone.now() - entry.pub_date
        if delta.days > 30:
            comment.is_public = False
        else:
            akismet_api = Akismet(key=settings.AKISMET_API_KEY, blog_url="http:/%s/"
                                  % Site.objects.get_current().domain)
        if akismet_api.verify_key():
            akismet_data = {'comment_type': 'comment',
                            'referrer': request.META['HTTP_REFERER'],
                            'user_ip': comment.ip_address,
                            'user_agent': request.META['HTTP_USER_AGENT']}
            print "checking comments successful !"
            if akismet_api.comment_check(smart_str(comment.comment),
                                         data=akismet_data,
                                         build_data=True):
                comment.is_public = False
comment_will_be_posted.connect(moderate_comment, sender=Comment)
예제 #7
0
from django.db import models
from django_comments.models import Comment
from django_comments.managers import CommentManager
from django_comments.signals import comment_will_be_posted

class RatingComment(Comment):
    objects = CommentManager()

    rating = models.IntegerField(blank=True, default=-1)

def make_sure_user_was_authenticated(sender, comment, request, **kwargs):
    return request.user.is_authenticated

comment_will_be_posted.connect(make_sure_user_was_authenticated)
예제 #8
0
    __str__ = __unicode__

@receiver(pre_save, sender=Spam)
def spam_save(sender, instance, **kwargs):
    logging.debug('Spam insert key: %d', instance.name)
    spamTrie.insert(instance.name)

@receiver(pre_delete, sender=Spam)
def spam_delete(sender, instance, **kwargs):
    logging.debug('Spam delete key: %d', instance.name)
    spamTrie.delete(instance.name)

spamwords = Spam.objects.all()
for key in spamwords:
    spamTrie.insert(key.name)

def spam_check(sender, comment, request, **kwargs):
    word = comment.comment

    while word:
        logging.debug('Spam check key: %d', word)
        if spamTrie.match(word):
            comment.is_public = False
            break

        word = word[1:]

    return True

comment_will_be_posted.connect(spam_check, sender=Comment, dispatch_uid="comment_spam_check_akismet")
예제 #9
0
    import hcomments
    request = kw['request']
    comment = kw['comment']

    data = request.POST.copy()
    if request.user.is_authenticated():
        if not data.get('name', ''):
            data["name"] = request.user.get_full_name() or request.user.get_username()
        if not data.get('email', ''):
            data["email"] = request.user.email
    form = hcomments.get_form(request)(comment, data)
    if not form.is_valid():
        raise CaptchaFailed()
    return True

comment_will_be_posted.connect(on_comment_will_be_posted)

def post_comment(request):
    from recaptcha_works.decorators import fix_recaptcha_remote_ip
    try:
        result = fix_recaptcha_remote_ip(comments_views.post_comment)(request)
    except CaptchaFailed:
        result = None

    if 'async' not in request.POST:
        if result:
            return result
        else:
            return comments_views.CommentPostBadRequest('')

    if result is None:
예제 #10
0
# -*- coding: utf-8 -*-"""

from django_comments.models import Comment
from django_comments.signals import comment_will_be_posted
from eurowiky.views import statement_extension


def comment_will_be_posted_handler(sender, **kwargs):
    if statement_extension._state.adding:
        statement_extension.save()


comment_will_be_posted.connect(comment_will_be_posted_handler, sender=Comment)
예제 #11
0

@receiver(pre_delete, sender=Spam)
def spam_delete(sender, instance, **kwargs):
    logging.debug('Spam delete key: %d', instance.name)
    spamTrie.delete(instance.name)


spamwords = Spam.objects.all()
for key in spamwords:
    spamTrie.insert(key.name)


def spam_check(sender, comment, request, **kwargs):
    word = comment.comment

    while word:
        logging.debug('Spam check key: %d', word)
        if spamTrie.match(word):
            comment.is_public = False
            break

        word = word[1:]

    return True


comment_will_be_posted.connect(spam_check,
                               sender=Comment,
                               dispatch_uid="comment_spam_check_akismet")