예제 #1
0
def report_abuse(request, item_id):
    themeitem = get_object_or_404(ThemeItem, id=item_id)

    try:
        ThemeAbuseReport.objects.get(themeitem=item_id)
        return render_response(request, "forum/forum_error.html",
                               {"message": "Bu ileti daha önce raporlanmış."})
    except ObjectDoesNotExist:
        if request.method == 'POST':
            form = AbuseForm(request.POST.copy())
            if form.is_valid():
                report = ThemeAbuseReport(themeitem=themeitem,
                                          submitter=request.user,
                                          reason=form.cleaned_data["reason"])
                report.save()

                email_subject = "Özgürlükİçin - Tema Şikayeti"
                email_body = """
%(topic)s başlıklı şikayet edildi.
İletiyi görmek için buraya tıklayın: %(link)s

İletinin içeriği: (<b>%(sender)s</b> tarafından yazılmış):
%(message)s
Şikayet metni buydu (%(reporter)s tarafından şikayet edilmiş):
%(reason)s
"""
                email_dict = {
                    "topic": themeitem.title,
                    "reporter": request.user.username,
                    "link": WEB_URL + themeitem.get_absolute_url(),
                    "message": striptags(render_bbcode(themeitem.text)),
                    "reason": striptags(report.reason),
                    "sender": themeitem.author.username,
                }
                send_mail(email_subject,
                          email_body % email_dict,
                          DEFAULT_FROM_EMAIL, [ABUSE_MAIL_LIST],
                          fail_silently=True)

                return render_response(
                    request, 'forum/forum_done.html', {
                        "message":
                        "İleti şikayetiniz ilgililere ulaştırılmıştır. Teşekkür Ederiz.",
                        "back": themeitem.get_absolute_url()
                    })
            else:
                return render_response(request, 'tema/report.html', {
                    "form": form,
                    "themeitem": themeitem
                })
        else:
            form = AbuseForm(auto_id=True)
            return render_response(request, 'tema/report.html', {
                "form": form,
                "themeitem": themeitem
            })
예제 #2
0
def report_abuse(request, post_id):
    post = get_object_or_404(Post, pk=post_id, hidden=False)
    if post.topic.locked:
        return render_response(
            request, "forum/forum_error.html",
            {"message": "Bu konu kilitlenmiş olduğu için raporlanamaz."})

    try:
        AbuseReport.objects.get(post=post_id)
        return render_response(request, "forum/forum_error.html",
                               {"message": "Bu ileti daha önce raporlanmış."})
    except ObjectDoesNotExist:
        if request.method == 'POST':
            form = AbuseForm(request.POST.copy())
            if form.is_valid():
                report = AbuseReport(post=post,
                                     submitter=request.user,
                                     reason=form.cleaned_data["reason"])
                report.save()
                # now send mail to staff
                email_subject = "Özgürlükİçin Forum - İleti Şikayeti"
                email_body = """
%(topic)s başlıklı konudaki bir ileti şikayet edildi.
İletiyi forumda görmek için buraya tıklayın: %(link)s

İletinin içeriği buydu (%(sender)s tarafından yazılmış):
%(message)s
Şikayet metni buydu (%(reporter)s tarafından şikayet edilmiş):
%(reason)s
"""
                email_dict = {
                    "topic": post.topic.title,
                    "reporter": request.user.username,
                    "link": WEB_URL + post.get_absolute_url(),
                    "message": striptags(render_bbcode(post.text)),
                    "reason": striptags(report.reason),
                    "sender": post.author.username,
                }
                send_mail(email_subject,
                          email_body % email_dict,
                          DEFAULT_FROM_EMAIL, [ABUSE_MAIL_LIST],
                          fail_silently=True)
                return render_response(
                    request, 'forum/forum_done.html', {
                        "message":
                        "İleti şikayetiniz ilgililere ulaştırılmıştır. Teşekkür Ederiz.",
                        "back": post.get_absolute_url()
                    })
        else:
            form = AbuseForm(auto_id=True)

        return render_response(request, "forum/report.html", locals())
예제 #3
0
def report_abuse(request, item_id):
    themeitem = get_object_or_404(ThemeItem, id=item_id)

    try:
        ThemeAbuseReport.objects.get(themeitem=item_id)
        return render_response(request, "forum/forum_error.html", {"message":"Bu ileti daha önce raporlanmış."})
    except ObjectDoesNotExist:
        if request.method == 'POST':
            form = AbuseForm(request.POST.copy())
            if form.is_valid():
                report = ThemeAbuseReport(themeitem=themeitem, submitter=request.user, reason=form.cleaned_data["reason"])
                report.save()

                email_subject = "Özgürlükİçin - Tema Şikayeti"
                email_body ="""
%(topic)s başlıklı şikayet edildi.
İletiyi görmek için buraya tıklayın: %(link)s

İletinin içeriği: (<b>%(sender)s</b> tarafından yazılmış):
%(message)s
Şikayet metni buydu (%(reporter)s tarafından şikayet edilmiş):
%(reason)s
"""
                email_dict = {
                        "topic":themeitem.title,
                        "reporter":request.user.username,
                        "link":WEB_URL + themeitem.get_absolute_url(),
                        "message":striptags(render_bbcode(themeitem.text)),
                        "reason":striptags(report.reason),
                        "sender":themeitem.author.username,
                        }
                send_mail(email_subject, email_body % email_dict, DEFAULT_FROM_EMAIL, [ABUSE_MAIL_LIST], fail_silently=True)

                return render_response(request, 'forum/forum_done.html', {
                    "message": "İleti şikayetiniz ilgililere ulaştırılmıştır. Teşekkür Ederiz.",
                    "back": themeitem.get_absolute_url()
                    })
            else:
                return render_response(request, 'tema/report.html', {"form": form, "themeitem": themeitem})
        else:
            form = AbuseForm(auto_id=True)
            return render_response(request, 'tema/report.html', {"form": form, "themeitem": themeitem})
예제 #4
0
def report_abuse(request,post_id):
    post = get_object_or_404(Post, pk=post_id, hidden=False)
    if post.topic.locked:
        return render_response(request, "forum/forum_error.html", {"message":"Bu konu kilitlenmiş olduğu için raporlanamaz."})

    try:
        AbuseReport.objects.get(post=post_id)
        return render_response(request, "forum/forum_error.html", {"message":"Bu ileti daha önce raporlanmış."})
    except ObjectDoesNotExist:
        if request.method == 'POST':
            form = AbuseForm(request.POST.copy())
            if form.is_valid():
                report = AbuseReport(post=post, submitter=request.user, reason=form.cleaned_data["reason"])
                report.save()
                # now send mail to staff
                email_subject = "Özgürlükİçin Forum - İleti Şikayeti"
                email_body ="""
%(topic)s başlıklı konudaki bir ileti şikayet edildi.
İletiyi forumda görmek için buraya tıklayın: %(link)s

İletinin içeriği buydu (%(sender)s tarafından yazılmış):
%(message)s
Şikayet metni buydu (%(reporter)s tarafından şikayet edilmiş):
%(reason)s
"""
                email_dict = {
                        "topic":post.topic.title,
                        "reporter":request.user.username,
                        "link":WEB_URL + post.get_absolute_url(),
                        "message":striptags(render_bbcode(post.text)),
                        "reason":striptags(report.reason),
                        "sender":post.author.username,
                        }
                send_mail(email_subject, email_body % email_dict, DEFAULT_FROM_EMAIL, [ABUSE_MAIL_LIST], fail_silently=True)
                return render_response(request, 'forum/forum_done.html', {
                    "message": "İleti şikayetiniz ilgililere ulaştırılmıştır. Teşekkür Ederiz.",
                    "back": post.get_absolute_url()
                    })
        else:
            form = AbuseForm(auto_id=True)

        return render_response(request, "forum/report.html", locals())
예제 #5
0
def reply(request, forum_slug, topic_id, quote_id=False):
    topic = get_object_or_404(Topic, pk=topic_id)

    posts = topic.post_set.order_by('-created')[:POSTS_PER_PAGE]

    if topic.locked:
        return render_response(request, "forum/forum_error.html",
                               {"message": "Başlık kilitli."})

    if request.method == 'POST':
        form = PostForm(request.POST.copy())

        flood, timeout = flood_control(request)

        if form.is_valid() and not flood:
            post = Post(topic=topic,
                        author=request.user,
                        text=form.cleaned_data['text'])
            post.save()

            # generate post url
            post_url = WEB_URL + post.get_absolute_url()
            # generate In-Reply-To header. If we get quote that should be quote's message id
            if request.POST.has_key('quote_id'):
                quote = get_object_or_404(Post, id=request.POST['quote_id'])
                in_reply_to = quote.get_email_id()
            else:
                in_reply_to = topic.get_email_id()

            # sorry, we have to send <style> to be able to display quotation correctly. Hardcode for now and I know, It's really UGLY!
            # FIXME: Give postmarkup.py's QuoteTag e-mail rendering support

            css = """<style type="text/css">
.quote {
    border: 1px solid #CCCCCC;
    padding: 10px;
    margin-bottom: 8px;
    background-color: #E1E3FF;
    color: #51615D;
}

.quote p {
    padding-left: 12px;
    font-style: italic;
}
</style>"""

            # send email to everyone who follows this topic.
            watchlists = WatchList.objects.filter(topic__id=topic_id)
            for watchlist in watchlists:
                send_mail_with_header(
                    '[Ozgurlukicin-forum] Re: %s' % topic.title,
                    '%s\n%s<br /><br /><a href="%s">%s</a>' %
                    (css, render_bbcode(
                        form.cleaned_data['text']), post_url, post_url),
                    '%s <%s>' % (request.user.username, FORUM_FROM_EMAIL),
                    [watchlist.user.email],
                    headers={
                        'Message-ID': post.get_email_id(),
                        'In-Reply-To': in_reply_to
                    },
                    fail_silently=True)

            # send mailing list also.
            # send_mail_with_header('Re: %s' % topic.title,
            #                       '%s\n%s<br /><br /><a href="%s">%s</a>' % (css, render_bbcode(form.cleaned_data['text']), post_url, post_url),
            #                       '%s <%s>' % (request.user.username, FORUM_FROM_EMAIL),
            #                       [FORUM_MESSAGE_LIST],
            #                       headers = {'Message-ID': post.get_email_id(),
            #                                  'In-Reply-To': in_reply_to},
            #                       fail_silently = True
            #                       )

            return HttpResponseRedirect(post.get_absolute_url())
    else:
        if quote_id:
            post = get_object_or_404(Post, pk=quote_id)

            if post in topic.post_set.all():
                form = PostForm(
                    auto_id=True,
                    initial={
                        'text':
                        '[quote <b>%s</b>, %s tarihinde:]%s[/quote]' %
                        (post.author, post.edited.strftime("%d/%m/%Y %H:%M"),
                         post.text)
                    })
            # if quote doesn't belong to this topic, just redirect to what user gets :)
            else:
                return HttpResponseRedirect(post.get_absolute_url())
        else:
            form = PostForm(auto_id=True)

    if request.user.has_perm("forum.can_change_abusereport"):
        abuse_count = AbuseReport.objects.count()

    return render_response(request, 'forum/reply.html', locals())
예제 #6
0
def reply(request, forum_slug, topic_id, quote_id=False):
    topic = get_object_or_404(Topic, pk=topic_id)

    posts = topic.post_set.order_by('-created')[:POSTS_PER_PAGE]

    if topic.locked:
        return render_response(request, "forum/forum_error.html", {"message": "Başlık kilitli."})

    if request.method == 'POST':
        form = PostForm(request.POST.copy())

        flood,timeout = flood_control(request)

        if form.is_valid() and not flood:
            post = Post(topic=topic,
                        author=request.user,
                        text=form.cleaned_data['text']
                       )
            post.save()

            # generate post url
            post_url = WEB_URL + post.get_absolute_url()
            # generate In-Reply-To header. If we get quote that should be quote's message id
            if request.POST.has_key('quote_id'):
                quote = get_object_or_404(Post, id=request.POST['quote_id'])
                in_reply_to = quote.get_email_id()
            else:
                in_reply_to = topic.get_email_id()

            # sorry, we have to send <style> to be able to display quotation correctly. Hardcode for now and I know, It's really UGLY!
            # FIXME: Give postmarkup.py's QuoteTag e-mail rendering support

            css = """<style type="text/css">
.quote {
    border: 1px solid #CCCCCC;
    padding: 10px;
    margin-bottom: 8px;
    background-color: #E1E3FF;
    color: #51615D;
}

.quote p {
    padding-left: 12px;
    font-style: italic;
}
</style>"""

            # send email to everyone who follows this topic.
            watchlists = WatchList.objects.filter(topic__id=topic_id)
            for watchlist in watchlists:
                send_mail_with_header('[Ozgurlukicin-forum] Re: %s' % topic.title,
                                      '%s\n%s<br /><br /><a href="%s">%s</a>' % (css, render_bbcode(form.cleaned_data['text']), post_url, post_url),
                                      '%s <%s>' % (request.user.username, FORUM_FROM_EMAIL),
                                      [watchlist.user.email],
                                      headers = {'Message-ID': post.get_email_id(),
                                                 'In-Reply-To': in_reply_to},
                                      fail_silently = True
                                      )

            # send mailing list also.
            # send_mail_with_header('Re: %s' % topic.title,
            #                       '%s\n%s<br /><br /><a href="%s">%s</a>' % (css, render_bbcode(form.cleaned_data['text']), post_url, post_url),
            #                       '%s <%s>' % (request.user.username, FORUM_FROM_EMAIL),
            #                       [FORUM_MESSAGE_LIST],
            #                       headers = {'Message-ID': post.get_email_id(),
            #                                  'In-Reply-To': in_reply_to},
            #                       fail_silently = True
            #                       )

            return HttpResponseRedirect(post.get_absolute_url())
    else:
        if quote_id:
            post = get_object_or_404(Post, pk=quote_id)

            if post in topic.post_set.all():
                form = PostForm(auto_id=True, initial={'text': '[quote <b>%s</b>, %s tarihinde:]%s[/quote]' % (post.author, post.edited.strftime("%d/%m/%Y %H:%M"), post.text)})
            # if quote doesn't belong to this topic, just redirect to what user gets :)
            else:
                return HttpResponseRedirect(post.get_absolute_url())
        else:
            form = PostForm(auto_id=True)

    if request.user.has_perm("forum.can_change_abusereport"):
        abuse_count = AbuseReport.objects.count()

    return render_response(request, 'forum/reply.html', locals())
예제 #7
0
def renderbbcode(context):
    return render_bbcode(context)