Exemplo n.º 1
0
def _process_new_article(request, article, is_new_topic, check_login):
    spam_status = antispam.conveyor.validate(request, article=article)

    # Detected spam is deleted independant on check_login because
    # an OpenID server may not return from a check and the spam will hang forever
    if spam_status == 'spam':
        forum = article.topic.forum
        article.delete()
        return response(request, 'cicero/spam.html', {
            'forum': forum,
            'text': article.text,
            'admins': [e for n, e in settings.ADMINS],
        })

    if check_login and not request.user.is_authenticated():
        form = AuthForm(request.session, {'openid_identifier': request.POST['name']})
        if form.is_valid():
            article.set_spam_status(spam_status)
            url = form.auth_redirect(post_redirect(request), data={'op': 'login', 'acquire': str(article.pk)})
            return redirect(url)
    if spam_status == 'clean':
        slug = article.topic.forum.slug
        _publish_article(slug, article)
        url = reverse(topic, args=[slug, article.topic_id])
        if not is_new_topic:
            url += '?page=last'
        url += '#%s' % article.id
        return redirect(url)
    # Любой не-clean и не-spam статус -- разного рода подозрения
    article.set_spam_status(spam_status)
    return response(request, 'cicero/spam_suspect.html', {
        'article': article,
    })
Exemplo n.º 2
0
def _process_new_article(request, article, is_new_topic, check_login):
    spam_status = antispam.conveyor.validate(request, article=article)

    # Detected spam is deleted independant on check_login because
    # an OpenID server may not return from a check and the spam will hang forever
    if spam_status == 'spam':
        forum = article.topic.forum
        article.delete()
        return response(request, 'cicero/spam.html', {
            'forum': forum,
            'text': article.text,
            'admins': [e for n, e in settings.ADMINS],
        })

    if check_login and not request.user.is_authenticated():
        form = AuthForm(request.session, {'openid_identifier': request.POST['name']})
        if form.is_valid():
            article.set_spam_status(spam_status)
            url = form.auth_redirect(post_redirect(request), data={'op': 'login', 'acquire': str(article.pk)})
            return redirect(url)
    if spam_status == 'clean':
        slug = article.topic.forum.slug
        _publish_article(slug, article)
        url = reverse(topic, args=[slug, article.topic_id])
        if not is_new_topic:
            url += '?page=last'
        url += '#%s' % article.id
        return redirect(url)
    # Любой не-clean и не-spam статус -- разного рода подозрения
    article.set_spam_status(spam_status)
    return response(request, 'cicero/spam_suspect.html', {
        'article': article,
    })
Exemplo n.º 3
0
def _process_new_comment(request, comment, language, check_login):
    spam_status = antispam.conveyor.validate(request, comment=comment)
    if spam_status == "spam":
        comment.delete()
        return render(request, "marcus/spam.html", {"text": comment.text, "admins": [e for n, e in settings.ADMINS]})
    if check_login and not request.user.is_authenticated():
        form = AuthForm(request.session, {"openid_identifier": request.POST["name"]})
        if form.is_valid():
            comment = models.Translation(comment, language)
            url = form.auth_redirect(request, target=comment.get_absolute_url(), data={"acquire": str(comment.pk)})
            return redirect(url)
    comment.spam_status = spam_status
    if spam_status == "clean":
        comment.approved = datetime.now()
    else:
        request.session["unapproved"] = comment.pk
    comment.save()
    return redirect(models.Translation(comment, language))
Exemplo n.º 4
0
Arquivo: views.py Projeto: 3cky/marcus
def _process_new_comment(request, comment, language, check_login):
    spam_status = antispam.conveyor.validate(request, comment=comment)
    if spam_status == 'spam':
        comment.delete()
        return render(request, 'marcus/spam.html', {
            'text': comment.text,
            'admins': [e for n, e in settings.ADMINS],
        })
    if check_login and not request.user.is_authenticated():
        form = AuthForm(request.session, {'openid_identifier': request.POST['name']})
        if form.is_valid():
            comment = models.Translation(comment, language)
            url = form.auth_redirect(request, target=comment.get_absolute_url(), data={'acquire': str(comment.pk)})
            return redirect(url)
    comment.spam_status = spam_status
    if spam_status == 'clean':
        comment.approved = datetime.now()
    else:
        request.session['unapproved'] = comment.pk
    comment.save()
    return redirect(models.Translation(comment, language))
Exemplo n.º 5
0
def _profile_forms(request):
    cicero_profile = request.user.cicero_profile
    try:
        scipio_profile = request.user.scipio_profile
    except ScipioProfile.DoesNotExist:
        scipio_profile = None
    return {
        'openid': AuthForm(request.session, initial={'openid_identifier': scipio_profile and scipio_profile.openid}),
        'personal': scipio_profile and ProfileForm(instance=scipio_profile),
        'settings': forms.SettingsForm(instance=cicero_profile),
        'object': cicero_profile,
    }