Esempio n. 1
0
def create_new_comment():
    vkid = request.form.get(VKID_NAME)
    post_id = request.form.get("post_id", None)
    text = request.form.get("text", None)
    if post_id and text:
        try:
            p = Post.get(Post.post_id == post_id)
            p.comments += 1
            p.save()
            Comment.create(post=p, author=vkid, text=text)
            return json.dumps({"success": 1})
        except DoesNotExist as e:
            print "Post with id='{0}' doesn't exist: {0}".format(e)
    return json.dumps({"success": 0})
Esempio n. 2
0
def create_new_comment():
    vkid = request.form.get(VKID_NAME)
    post_id = request.form.get("post_id", None)
    text = request.form.get("text", None)
    if post_id and text:
        try:
            p = Post.get(Post.post_id == post_id)
            p.comments += 1
            p.save()
            Comment.create(post=p, author=vkid, text=text)
            return json.dumps({"success": 1})
        except DoesNotExist as e:
            print "Post with id='{0}' doesn't exist: {0}".format(e)
    return json.dumps({"success": 0})
Esempio n. 3
0
def demo_add_comment(author_id, post_id):
    _, words_amount, text = generate_sentence()
    try:
        if author_id:
            Person.get(Person.vkid == author_id)
        else:
            all_pers = Person.select(Person.vkid)
            count = all_pers.count() - 1
            author_id = all_pers[random.randint(0, count)]

        if post_id:
            p = Post.get(Post.post_id == post_id)
        else:
            all_posts = Post.select()
            count = all_posts.count() - 1
            p = all_posts[random.randint(0, count)]
            p.comments += 1
            p.save()
        Comment.create(post=p, author=author_id, text=text)
        return True
    except DoesNotExist:
        return False
Esempio n. 4
0
def demo_add_comment(author_id, post_id):
    _, words_amount, text = generate_sentence()
    try:
        if author_id:
            Person.get(Person.vkid == author_id)
        else:
            all_pers = Person.select(Person.vkid)
            count = all_pers.count() - 1
            author_id = all_pers[random.randint(0, count)]

        if post_id:
            p = Post.get(Post.post_id == post_id)
        else:
            all_posts = Post.select()
            count = all_posts.count() - 1
            p = all_posts[random.randint(0, count)]
            p.comments += 1
            p.save()
        Comment.create(post=p, author=author_id, text=text)
        return True
    except DoesNotExist:
        return False