Beispiel #1
0
def preview_comment(request):
    if request.method == "POST":
        try:
            validate_comment(request, preview=True)
        except CommentError, e:
            return Response(json_response(status='error', message=e.message)
                 ,   mimetype='application/json')

        return Response(
                json_response(status='success',
                    comment=get_template('comment').
                            get_def('individual_comment').
                            render(comment=new_comment(request),
                    preview=True))
        , mimetype='application/json')
Beispiel #2
0
def add_comment(request):
    if request.method == "POST":
        try:
            validate_comment(request)
        except CommentError, e:
            return Response ( json_response(status='error', message=e.message)
                    , mimetype='application/json')

        comment = new_comment(request)
        comment.save()

        invalidate_page_cache(request.form['page_id'])

        return Response(
                json_response(status='success',
                    comment=get_template('comment').
                            get_def('individual_comment').
                            render(comment=comment))
        , mimetype='application/json')
Beispiel #3
0
    if config.use_cache:
        cache_del('individual_page_%s' % map.request_path)
    
    return redirect('/c/%d' % comment.comment_id)


def handle_comment_preview(request, map):
    try:
        validate_comment(request, preview=True)
    except CommentError, e:
        return page_with_comment_error(request, map, e.message)

    comment = new_comment(request)
    comment_preview = (get_template('comment').
                         get_def('individual_comment').
                         render(comment=comment, preview=True))

    template_data = default_page_template_data(request, map)
    template_data['comment_data']['comment_preview'] = comment_preview

    return display_page(**template_data)


def page_with_comment_error(request, map, error):
    template_data = default_page_template_data(request, map)
    template_data['comment_data']['comment_error'] = error

    return display_page(**template_data)

Beispiel #4
0
        validate_comment(request)
    except CommentError, e:
        return comment_error(request, comment_id, e.message)

    comment = new_comment(request)
    comment.save()

    invalidate_page_cache(request.form["page_id"])

    return redirect("/c/%d" % comment.comment_id)


def handle_comment_preview(request, comment_id):
    try:
        validate_comment(request, preview=True)
    except CommentError, e:
        return comment_error(request, comment_id, e.message)

    comment = new_comment(request)
    comment_preview = get_template("comment").get_def("individual_comment").render(comment=comment, preview=True)

    template_data = default_comment_template_data(request, comment_id)
    template_data["comment_preview"] = comment_preview
    template_data["reply"] = True

    return display_page(template_data)


def display_page(template_data):
    return display_template("comment_page", **template_data)