Пример #1
0
def upvote():
    global up_count 
    global upvote
    global down_count
    up_count += 1
    if up_count % 2 == 0: 
        mongoBook.upvote_(file_id)
        upvote -= 1
        print('not up anymore')
    elif up_count % 2 != 0:
        mongoBook.upvote(file_id)
        upvote += 1
        print('up')
    return str(upvote)
Пример #2
0
def downvote():
    global down_count
    global downvote
    global up_count
    down_count += 1 
    if down_count % 2 == 0: 
        mongoBook.upvote_(file_id)
        downvote -= 1
        print('not down anymore')
    elif down_count % 2 != 0:
        mongoBook.upvote(file_id)
        downvote += 1
        print('down')
    return str(downvote)
Пример #3
0
def upvote():
    global up_count
    global upvote
    global down_count

    user_id = id_
    if user_id in mongoBook.get_up(file_id):
        mongoBook.upvote_(file_id, user_id)
        print('not up anymore')
    elif user_id not in mongoBook.get_up(file_id) and user_id not in mongoBook.get_down(file_id):
        mongoBook.upvote(file_id, user_id)
        print('up')
    # elif user_id in mongoBook.get_down(file_id):
    #     return "You already downvoted!"

    return str(len(mongoBook.get_up(file_id)))